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.
Suppose I insert 1
then insert 79 , max stack = 1,79
then insert 29 , which wont be inserted into max stack coz 29<79
now I pop which makes max stac -> 1
then if i print max element answer will be 1
but answer supposed to be 29
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 →
Suppose I insert 1 then insert 79 , max stack = 1,79 then insert 29 , which wont be inserted into max stack coz 29<79 now I pop which makes max stac -> 1 then if i print max element answer will be 1 but answer supposed to be 29