Untitled
user_9124840
plain_text
a year ago
443 B
10
Indexable
class Solution {
public:
bool backspaceCompare(string s, string t) {
return afterBackspacing(s) == afterBackspacing(t);
}
string afterBackspacing(string s) {
string temp = "";
for (char ch : s) {
if (ch == '#') {
if (!temp.empty())
temp.pop_back();
} else
temp.push_back(ch);
}
return temp;
}
};Editor is loading...
Leave a Comment