题解 | #合并两个有序的数组#
合并两个有序的数组
http://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665
import java.util.*;
public class Solution {
public void merge(int A[], int m, int B[], int n) {
int length = m + n -1;
for(int i = m-1,j =n-1;length>i;length--){
if(i==-1){
A[length] = B[j];
j--;
continue;
}
if(j==-1){
A[length] = A[i];
i--;
continue;
}
if(A[i]>B[j]){
A[length] = A[i];
i--;
}else{
A[length] = B[j];
j--;
}
}
}
}