A utility function to find minimum in arr [ l . . h ]
function min ( arr , l , h ) { var mn = arr [ l ] ; for ( i = l + 1 ; i <= h ; i ++ ) { if ( mn > arr [ i ] ) { mn = arr [ i ] ; } } return parseInt ( mn ) ; }