Back to course home
0% completed
Vote For New Content
Double pointer approach is an overkill here
Denys Stopkin
Jul 2, 2025
static std::string deleteBackspaces(const std::string& str)
{
std::string result;
for (int i = 0; i < str.size(); ++i)
{
if (str[i] != '#')
{
result.push_back(str[i]);
}
else
{
if (!result.empty())
{
result.pop_back();
}
}
}
return result;
}
static bool compare(const std::string& str1, const std::string& str2)
{
return deleteBackspaces(str1) == deleteBackspaces(str2);
}
0
0
Comments
Comments
On this page