Untitled
user_9124840
plain_text
09/02/2024 3:58 PM
452 B
18
Indexable
class Solution {
public:
string removeDuplicates(string s) {
string ans = "";
for (char ch : s) {
if (ans.empty() || ch != ans.back()) {
ans.push_back(ch);
} else {
ans.pop_back();
}
}
return ans;
}
};Editor is loading...
Leave a Comment