Untitled
user_9124840
plain_text
a year ago
338 B
10
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