Finding the r [ ] and l [ ] arrays .
for ( var j = 1 ; j < n ; j ++ ) { L . push ( 2 * freq [ j - 1 ] - j ) ; R . push ( 2 * freq [ j ] - j ) ; } var max_len = - 2147483648 ; var min_val = 2147483648 ;