static MinMax minmax ( int [ ] input , final int start , final int length ) { int max = input [ start ] ; int min = max ; for ( int i = length - 2 , index = start + 1 ; i >= 0 ; i -- , index ++ ) { final int v = input [ index ] ; if ( v > max ) { max = v ; } if ( v < min ) { min = v ; } } return new MinMax ( min , max ) ; }
Calculate minimum and maximum value for a slice of an array .