public static int [ ] Unique ( int [ ] values ) { HashSet < Integer > lst = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < values . length ; i ++ ) { lst . add ( values [ i ] ) ; } int [ ] v = new int [ lst . size ( ) ] ; Iterator < Integer > it = lst . iterator ( ) ; for ( int i = 0 ; i < v . length ; i ++ ) { v [ i ] = it . next ( ) ; } return v ; }
Get unique values form the array .