void (int[] sequence, int[] expected) { int max = 0; for (int aSequence : sequence) { max = Math.max(aSequence + 1, max); } int[] first = new int[sequence.length]; int[] second = new int[max + 2]; for (int i = 0; i < sequence.length; i++) { assertEquals("Elements in sequence should be unique", 0, second[sequence[i]]); first[i] = i + 1; second[sequence[i]] = i + 1; } int[][] result = buildChange(first, second); assertEquals(result[0].length, result[1].length); assertEquals(result[0].length, expected.length); for (int i = 0; i < expected.length; i++) { assertEquals(expected[i], sequence[result[0][i]]); } }