Javascript implementation of the approach
function findIndices ( arr , n ) { let leftMin = 0 , rightMin = 0 ; let leftMax = 0 , rightMax = 0 ; let min = arr [ 0 ] , max = arr [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) {