public static boolean validateIsr(int[] replicas, int[] isr) {
        if (isr.length == 0) return true;
        if (replicas.length == 0) return false;
        int[] sortedReplicas = clone(replicas);
        Arrays.sort(sortedReplicas);
        int[] sortedIsr = clone(isr);
        Arrays.sort(sortedIsr);
        int j = 0;
        if (sortedIsr[0] < 0) return false;
        int prevIsr = -1;
        for (int curIsr : sortedIsr) {
            if (prevIsr == curIsr) return false;
            prevIsr = curIsr;
            while (true) {
                if (j == sortedReplicas.length) return false;
                int curReplica = sortedReplicas[j++];
                if (curReplica == curIsr) break;
            }
        }
        return true;
    }
@Test
    public void testValidateIsr() {
        assertTrue(Replicas.validateIsr(new int[] {}, new int[] {}));
        assertTrue(Replicas.validateIsr(new int[] {1, 2, 3}, new int[] {}));
        assertTrue(Replicas.validateIsr(new int[] {1, 2, 3}, new int[] {1, 2, 3}));
        assertTrue(Replicas.validateIsr(new int[] {3, 1, 2}, new int[] {2, 1}));
        assertFalse(Replicas.validateIsr(new int[] {3, 1, 2}, new int[] {4, 1}));
        assertFalse(Replicas.validateIsr(new int[] {1, 2, 4}, new int[] {4, 4}));
    }