public int[] merge(int[] arr1, int[] arr2) {
        int[] ans = new int[arr1.length + arr2.length];
        int i = 0, index1 = 0, index2 = 0;
        while (index1 < arr1.length && index2 < arr2.length) {
            if (arr1[index1] < arr2[index2]) {
                ans[i++] = arr1[index1++];
            } else {
                ans[i++] = arr2[index2++];
            }
        }
        while (index1 < arr1.length) {
            ans[i++] = arr1[index1];
        }
        while (index2 < arr2.length) {
            ans[i++] = arr2[index2++];
        }
        return ans;
    }