We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If the stack is empty just push the element
else If an element is smaller than the top of the stack then take xor with the top of the stack and pop the element until element become greater than the top of the stack.
if an element is greater than the top of the stack take xor with top of the stack and push it.
Really easy implementation. If any doubt, ping me :)
Cookie support is required to access HackerRank
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 →
If the stack is empty just push the element else If an element is smaller than the top of the stack then take xor with the top of the stack and pop the element until element become greater than the top of the stack. if an element is greater than the top of the stack take xor with top of the stack and push it. Really easy implementation. If any doubt, ping me :)