Finding the minimum and maximum values in given array .
int maxvalue = - 2147483647 , 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 ] ; for ( int i = 0 ; i < maxvalue + 2 ; i ++ ) { mark [ i ] = 0 ; value [ i ] = 0 ; }