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.
This is a good point. The instruction was "1 x -Push the element x into the stack" but if we use the one stack hack then we are violating this instruction. We may not be using the stack for anything but printing the maximum but another user may also wish to use the stack. Programming this way also makes extending the program more difficult.
At the very minimum, I would be asking the customer if they needed the stack preserved.
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 →
This is a good point. The instruction was "1 x -Push the element x into the stack" but if we use the one stack hack then we are violating this instruction. We may not be using the stack for anything but printing the maximum but another user may also wish to use the stack. Programming this way also makes extending the program more difficult.
At the very minimum, I would be asking the customer if they needed the stack preserved.