• + 0 comments

    My Python Solution

    def andXorOr(a):
        stack = [a[0], a[1]]
        S = a[0] ^ a[1]
        for i in range(2, len(a)):
            while len(stack) > 0 and stack[-1] >= a[i]:
                S = max(S, stack[-1] ^ a[i])
                stack.pop()
            if len(stack) > 0:
                S = max(S, stack[-1] ^ a[i])
            stack.append(a[i])
        return S