Borward traversal
while ( sForward . Count != 0 && arr [ i ] < arr [ sForward . Peek ( ) ] ) { ans = Math . Max ( ans , arr [ i ] ^ arr [ sForward . Peek ( ) ] ) ; sForward . Pop ( ) ; } sForward . Push ( i ) ;