public void merge(int A[], int m, int B[], int n) {
        if (A == null || B == null) {
            return;
        }

        int total = m + n;
        int indexA = 0;
        int indexB = 0;
        int[] c = new int[total];
        for (int i = 0; i < total; i++) {
            if (indexA < m && indexB < n) {
                if (A[indexA] <= B[indexB]) {
                    c[i] = A[indexA++];
                } else {
                    c[i] = B[indexB++];
                }
            } else if (indexA == m) {
                c[i] = B[indexB++];
            } else if (indexB == n) {
                c[i] = A[indexA++];
            }
        }

        for (int i = 0; i < total; i++) {
            A[i] = c[i];
        }
    }