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.
for (unsigned long int i = 1; i < s.size(); i++ )
{
if (!ac.empty()) //stack shoud not empty
{
ts = ac.top(); //stack top value
if (ts == s[i]) { //topof stack copmared to string value one by one
ac.pop();
}
else if (ts != s[i]) {
ac.push(s[i]);
}
}
else {
ac.push(s[i]);
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
std::sort(s.begin(), s.end()); ac.push(s[0]);