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++]; } }