Here you can find the source of negate(int[] x, int Max)
static int[] negate(int[] x, int Max)
//package com.java2s; //License from project: Apache License public class Main { /**/*ww w . ja va 2s . co m*/ * output all integers from the range [0,Max) that are not * in the array */ static int[] negate(int[] x, int Max) { int[] ans = new int[Max - x.length]; int i = 0; int c = 0; for (int j = 0; j < x.length; ++j) { int v = x[j]; for (; i < v; ++i) ans[c++] = i; ++i; } while (c < ans.length) ans[c++] = i++; return ans; } }