CommonTwo
public int commonTwo(String[] a, String[] b) {
int startA=0;
int startB=0;
int count=0; while((( startA < a.length ) && ( startB < b.length )))
{
if(startA >0){
if(a[startA].equals(a[startA-1])){
startA++;
continue;
}
}
if(startB >0){
if(b[startB].equals(b[startB-1])){
startB++;
continue;
}
} if( a[startA].equals(b[startB]) ){
count++;
startA++;
startB++;
}
else if( (a[startA].compareTo(b[startB])) < 0 ){
startA++;
}
else{
startB++;
} }
return count; }
http://codingbat.com/prob/p100369
CommonTwo的更多相关文章
随机推荐
- S/4HANA和CRM Fiori应用的搜索分页实现
在我的博客Paging Implementation in S/4HANA for Customer Management 我介绍了S/4HANA for Customer Management里采用 ...
- selenium安装及官方文档
selenium-python官方文档: https://selenium-python.readthedocs.io/ python3.5已安装的情况下,安装示意图如下 命令行输入 pip3 ins ...
- 课程设计__继承与派生,重载<<
///继承与派生 #include <iostream> using namespace std; class Point { public: Point (,):x(a),y(b) {} ...
- 【转】关于Eclipse创建Android项目时,会多出一个appcompat_v7的问题
问题描述: 使用eclipse创建一个Android项目时,发现project列表中会多创建出一个appcompat_v7项目,再创建一个Android项目时,又会再多出一个appcompat_v7_ ...
- Family Gathering at Christmas(思维题)
Family Gathering at Christmas 时间限制: 1 Sec 内存限制: 128 MB提交: 13 解决: 4[提交] [状态] [讨论版] [命题人:admin] 题目描述 ...
- Java 序列化对象工具类
SerializationUtils.java package javax.utils; import java.io.ByteArrayInputStream; import java.io.Byt ...
- openstack cinder api对应的命令行接口
a) Create Volume cinder create 1 --display-name admin-volume1 cinder create --display-na ...
- mysql 自增主键为什么不是连续的?
由于自增主键可以让主键索引尽量地保持递增顺序插入,避免了页分裂,因此索引更紧凑 MyISAM 引擎的自增值保存在数据文件中 nnoDB 引擎的自增值,其实是保存在了内存里,并且到了 MySQL 8.0 ...
- mysql指定id默认第一
有个需求 家庭创建人要默认排第一,刚开始用加入家庭的时间排序可以 好简单, 后来加了一个需求 家庭创建人可以转移,结果按时间排序就不行了,又不想去写循环重新排序 就各种百度, 等于就是指定ID排最后 ...
- python-读写文件的方式
open(path, flag[, encoding][, errors]) path:要打开文件的路径 flag:打开方式 r 以只读的方式打开文件,文件的描述符放在文件的开头 rb 以二进制格式打 ...