Untitled
user_9124840
plain_text
10 months ago
338 B
5
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