题解 | #合并两个有序的数组#
合并两个有序的数组
http://www.nowcoder.com/practice/89865d4375634fc484f3a24b7fe65665
public class Solution { public void merge(int A[], int m, int B[], int n) { int[] C = new int[m]; for(int i = 0 ; i < m ; i++) C[i] = A[i]; int i = 0 , j = 0 , k = 0; while(i < m && j < n) { if(C[i] <= B[j]) A[k++] = C[i++]; else if(C[i] > B[j]) A[k++] = B[j++]; } while(j < n) A[k++] = B[j++]; while(i < m) A[k++] = C[i++]; } }