Final check whether there are any elements which are equal to the maximum
while ( i >= 0 && arr [ i ] == max ) { leftMax = i ; i -- ; } return leftMax ; } let arr = [ 0 , 0 , 1 , 2 , 5 , 5 , 6 , 8 , 8 ] ; let n = arr . length ;