62,614
社区成员
发帖
与我相关
我的任务
分享
public static int find(int[]a,int[]b) {
if(a[a.length-1]<=b[0]) return a[a.length-1];
int result = 0;
int i=0;int j=0;
int count = 2;
int tempA = a[0];int tempB = b[0];
while(true) {
if(i == a.length) return a[a.length-1];
if(j == b.length) return b[a.length-1];
if(count == a.length) {
result = Math.max(tempA, tempB);
break;
}
if(a[i+1] < b[j+1]) {
i++;
tempA = a[i];
count++;
}else {
j++;
tempB = b[j];
count++;
}
}
return result;
}