public static int removeConsecutiveDuplicates(int[] arr, int end) {
        int curr = 0;
        for (int i = 1; i < end; ++i) {
            if (arr[i] != arr[curr])
                arr[++curr] = arr[i];
        }
        return curr + 1;
    }
@Test
    public void removeConsecutiveDuplicates() {
        int[] arr = new int[]{3, 3, 4, 2, 1, -3, -3, 9, 3, 6, 6, 7, 7};
        assertEquals(9, ArrayUtil.removeConsecutiveDuplicates(arr, arr.length));
        // note that only the first 9 elements should be considered the 'valid' range
        assertEquals(IntArrayList.from(3, 4, 2, 1, -3, 9, 3, 6, 7, 6, 6, 7, 7), IntArrayList.from(arr));

        int[] brr = new int[]{4, 4, 3, 5, 3};
        assertEquals(2, ArrayUtil.removeConsecutiveDuplicates(brr, 3));
        assertEquals(IntArrayList.from(4, 3, 3, 5, 3), IntArrayList.from(brr));
    }