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 [ ++ ] = i ; ++ i ; } while ( c < ans . length ) ans [ c ++ ] = i ++ ; return ans ; }
output all integers from the range [ 0 Max ) that are not in the array