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.
close your eyes and put the two stacks side by side, i mean maximum element vs. non-maximum...you see that you don't need the element stack at all, don't you?
if you think about it in terms of recursive processes e.g. function calls, you'll realize that all you need to store is the return value (the maximum); the argument is of no use to you after you have made the function call.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximum Element
You are viewing a single comment's thread. Return to all comments →
close your eyes and put the two stacks side by side, i mean maximum element vs. non-maximum...you see that you don't need the element stack at all, don't you?
if you think about it in terms of recursive processes e.g. function calls, you'll realize that all you need to store is the return value (the maximum); the argument is of no use to you after you have made the function call.