Untitled
user_9124840
plain_text
8 days ago
443 B
2
Indexable
Never
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; } };
Leave a Comment