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.
The "max stack" contains all the distinct max values, so after popping from the max stack, the "max stack" top would have the max of all the elements in the "elements stack", which makes the "elements stack" redundant.
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 →
The "max stack" contains all the distinct max values, so after popping from the max stack, the "max stack" top would have the max of all the elements in the "elements stack", which makes the "elements stack" redundant.