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的更多相关文章
随机推荐
- Metasploitable渗透测试实战——生成木马
攻击机:kali 目标机:windows 1.生成木马 wincap发送至本机 2.进入msf (命令:msfconsole)启动监听 3.当目标点击test.exe(可伪装)时,触发后门,实现入 ...
- C4C销售订单中业务伙伴的自动决定功能Partner determination procedure
例子:我新建一个Sales Order,account 字段选择ID为1001的Account:Porter LLC 创建成功后,观察这个Sales Order的Involved Party里,Bil ...
- 【HHHOJ】ZJOI2019模拟赛(十五)03.17 解题报告
点此进入比赛 得分: \(42+10+14=66\) 排名: \(Rank\ 3\) \(Rating\):\(+53\) \(T1\):[HHHOJ200]稗田的梦中之梦(点此看题面) 暴力\(DF ...
- @RequestMapping,@ResponseBody,@RequestBody用法
本文转载:http://blog.csdn.net/ff906317011/article/details/78552426 1.@RequestMapping 国际惯例先介绍什么是@RequestM ...
- JS获取页面传过来的值
利用JS获取页面的传值,此方法只适应Get传值. 获取页面之间的传值,在后台我们很容易获取,那我们在前台只利用JS怎么写呢? 在看代码之前你需要了解的 ① 参考:W3C Location 对象 Loc ...
- C# unchecked运算符
一.C# unchecked运算符 unchecked运算符用于取消整型算术运算和转换的溢出检查. 二.提示 默认情况下,都是unchecked选项.因此,只有在需要把几个未检查的代码行放在一个明确标 ...
- Mybatis查询报错:There is no getter for property named '*' in 'class java.lang.String
问题: 执行查询时报错:There is no getter for property named '*' in 'class java.lang.String 原因: 传过去的参数为识别.本例为 p ...
- 关于 ReactNative 环境搭建之 error: invalid developer directory '/Library/Developer/CommandLineTools' - RN
简要说明,此次尝试安装 ReactNative 时当前 MacPro 版本为 10.13.6.Xcode 版本为 Version 9.4.1 (9F2000),按照官方的完整原生环境搭建流程一步步执行 ...
- CodeForces_864_bus
C. Bus time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...
- MySQL的where条件优化
where 条件优化 适合select delete update 1.避免无用的括号 ((a AND b) AND c OR (((a AND b) AND (c AND d)))) -> ...