You are viewing a single comment's thread. Return to all comments →
def andXorOr(a): ans = 0 st = [] for i in range(len(a)): while len(st) != 0 and st[-1] > a[i]: st.pop() if len(st) != 0: ans = max(ans, a[i] ^ st[-1]) st.append(a[i]) while len(st) != 0: st.pop() for i in range(len(a) - 1, -1, -1): while len(st) != 0 and st[-1] > a[i]: st.pop() if len(st) != 0: ans = max(ans, a[i] ^ st[-1]) st.append(a[i]) return ans
Seems like cookies are disabled on this browser, please enable them to open this website
AND xor OR
You are viewing a single comment's thread. Return to all comments →