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.
Nice approach.
if we try greedy then there is problem in case where both corrosponding stack have same elements.
Actually if we have problem in traversing both the stack
simultaneously the best approach is to first traverse the 1st stack then start traversing second stack and manupulate the last
added element from 1st stack as required in question.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Two Stacks
You are viewing a single comment's thread. Return to all comments →
Nice approach. if we try greedy then there is problem in case where both corrosponding stack have same elements. Actually if we have problem in traversing both the stack simultaneously the best approach is to first traverse the 1st stack then start traversing second stack and manupulate the last added element from 1st stack as required in question.