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.
because empty string would also count as previous state of string .
eg "1 abc","3 3","4" would yield an empty string as previous state
we maintain the stack in order to keep the previous states of the string and consequently we perform perations;
youcan optimize the space in stack by checking before push :
if(stack.top()!+string)stack.push(string);
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 →
because empty string would also count as previous state of string . eg "1 abc","3 3","4" would yield an empty string as previous state we maintain the stack in order to keep the previous states of the string and consequently we perform perations; youcan optimize the space in stack by checking before push : if(stack.top()!+string)stack.push(string);