Borward traversal
while ( ! sForward . empty ( ) && arr [ i ] < arr [ sForward . top ( ) ] ) { ans = max ( ans , arr [ i ] ^ arr [ sForward . top ( ) ] ) ; sForward . pop ( ) ; } sForward . push ( i ) ;