Vector to store the left and right index for each i such that left [ i ] > arr [ i ] and right [ i ] > arr [ i ]
vector < int > left ( n ) , right ( n ) ; stack < pair < int , int > > s ; s . push ( { INT_MAX , -1 } ) ;