private int[] merge(int[] a1, int[] a2) {
        int[] result = new int[a1.length + a2.length];
        int i = 0;
        int j = 0;
        int k = 0;
        while (i < a1.length || j < a2.length) {
            if (i == a1.length) {
                result[k++] = a2[j++];
            } else if (j == a2.length) {
                result[k++] = a1[i++];
            } else if (a1[i] > a2[j]) {
                result[k++] = a1[i++];
            } else if (a1[i] < a2[j]) {
                result[k++] = a2[j++];
            } else {
                if (isGreater(a1, a2, i, j)) {
                    result[k++] = a1[i++];
                } else {
                    result[k++] = a2[j++];
                }
            }
        }
        return result;
    }
Date 03/01/2016
@author Tushar Roy

Given two arrays of length m and n with digits 0-9 representing two numbers.
Create the maximum number of length k <= m + n from digits of the two

e.g
nums1 = [3, 4, 6, 5]
nums2 = [9, 1, 2, 5, 8, 3]
k = 5
return [9, 8, 6, 5, 3]

https://leetcode.com/problems/create-maximum-number/
src/com/interview/array/MaxNumberFromTwoArray.java