public static int[] merge(int[] a, int[] b) {
        if (a.length + b.length == 0)
            return new int[]{};
        int[] result = new int[a.length + b.length];
        int size = 0;
        int i = 0;
        int j = 0;
        while (i < a.length && j < b.length) {
            if (a[i] < b[j])
                result[size++] = a[i++];
            else
                result[size++] = b[j++];
        }
        if (i == a.length) {
            System.arraycopy(b, j, result, size, b.length - j);
            size += b.length - j;
        } else {
            System.arraycopy(a, i, result, size, a.length - i);
            size += a.length - i;
        }
        int sizeWithoutDuplicates = removeConsecutiveDuplicates(result, size);
        return Arrays.copyOf(result, sizeWithoutDuplicates);
    }
@Test
    public void testMerge() {
        assertArrayEquals(new int[]{}, ArrayUtil.merge(new int[]{}, new int[]{}));
        assertArrayEquals(new int[]{4, 5}, ArrayUtil.merge(new int[]{}, new int[]{4, 5}));
        assertArrayEquals(new int[]{4, 5}, ArrayUtil.merge(new int[]{4, 5}, new int[]{}));
        assertArrayEquals(new int[]{3, 6, 9}, ArrayUtil.merge(new int[]{6, 6, 6, 9}, new int[]{3, 9}));
        int[] a = {2, 6, 8, 12, 15};
        int[] b = {3, 7, 9, 10, 11, 12, 15, 20, 21, 26};
        assertEquals(from(2, 3, 6, 7, 8, 9, 10, 11, 12, 15, 20, 21, 26), from(ArrayUtil.merge(a, b)));
    }