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.
In this problem,by using stack,the basic idea is to store each modified string after the append or delete operation
performed on them.
Now the fourth option is to undo last step on string and as the previous modified(last modified) string must be on the top of stack
so here we have to pop it(st.pop()).After poping,the top of stack will now point that string which it was before performing
the last modification operation (append or delete) on it
and we will now store its present top element in s ie s=st.peek()
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Text Editor
You are viewing a single comment's thread. Return to all comments →
In this problem,by using stack,the basic idea is to store each modified string after the append or delete operation performed on them. Now the fourth option is to undo last step on string and as the previous modified(last modified) string must be on the top of stack so here we have to pop it(st.pop()).After poping,the top of stack will now point that string which it was before performing the last modification operation (append or delete) on it and we will now store its present top element in s ie s=st.peek()