You are viewing a single comment's thread. Return to all comments →
My JS Solution
function andXorOr(A) { var stack = [A[0], A[1]]; var S = A[0] ^ A[1]; for(let i = 2; i < A.length; i++){ while(stack.length > 0 && stack.slice(-1) >= A[i]){ S = Math.max(S, stack.slice(-1) ^ A[i]); stack.pop(); } if(stack.length > 0) S = Math.max(S, stack.slice(-1) ^ A[i]); stack.push(A[i]) } return S; }
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 →
My JS Solution