Borward traversal
while ( sForward . length != 0 && arr [ i ] < arr [ sForward [ sForward . length - 1 ] ] ) { ans = Math . max ( ans , arr [ i ] ^ arr [ sForward [ sForward . length - 1 ] ] ) ; sForward . pop ( ) ; } sForward . push ( i ) ;