class Solution {
/**
* @param A and B: sorted integer array A and B.
* @return: A new sorted integer array
*/
public ArrayList mergeSortedArray(ArrayList A, ArrayList B) {
// write your code here
ArrayList merge = new ArrayList();
int aSize = A.size();
int bSize = B.size();
int i = 0;
int j = 0;
while(i<aSize && j<bSize){
if(A.get(i)< = B.get(j)){
merge.add(A.get(i));
i++;
}else{
merge.add(B.get(j));
j++;
}
}
while(i<aSize){
merge.add(A.get(i));
i++;
}
while(j<bSize){
merge.add(B.get(j));
j++;
}
return merge;
}
}
转载于:https://www.cnblogs.com/yiwenhao/p/7407520.html