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.
Actually Yes. DivyanshuJ is true.
This code just stores the max value in the stack. What happens if somehow the max value is popped and the second largest value is the required answer?
This question can only be understood if the snippet
st.push(max(x,st.top()));
is explained properly.
What is actually happening to the top pointer inside that function is really a mystery.
Maximum Element
You are viewing a single comment's thread. Return to all comments →
Actually Yes. DivyanshuJ is true. This code just stores the max value in the stack. What happens if somehow the max value is popped and the second largest value is the required answer?
This question can only be understood if the snippet
is explained properly. What is actually happening to the top pointer inside that function is really a mystery.
Tags: #DivyanshuJ #hariom7 #ayeshamatloob #haruelrovix