Finding the minimum and maximum values in given array .
int maxvalue = - 2147483647 ; int minvalue = 2147483647 ; for ( int i = 0 ; i < n ; i ++ ) { maxvalue = Math . max ( maxvalue , arr [ i ] ) ; minvalue = Math . min ( minvalue , arr [ i ] ) ; } int mark [ ] = new int [ maxvalue + 2 ] ; int value [ ] = new int [ maxvalue + 2 ] ; Arrays . fill ( mark , 0 ) ; Arrays . fill ( value , 0 ) ;