If arr [ i ] = max then rightmost index for max will change
else if ( arr [ i ] == max ) rightMax = i ; } document . write ( " " + leftMin + " " ) ; document . write ( " " + rightMin + " " ) ; document . write ( " " + leftMax + " " ) ; document . write ( " " + rightMax + " " ) ; }