Vector to store the left and right index for each i such that left [ i ] > arr [ i ] and right [ i ] > arr [ i ]
left = [ 0 ] * n NEW_LINE right = [ 0 ] * n NEW_LINE s = [ ] NEW_LINE s . append ( ( sys . maxsize , - 1 ) ) NEW_LINE