LeetCode 1047. Remove All Adjacent Duplicates In String Posted on 2021-03-09 Edited on 2024-11-24 In LeetCode 123456789101112class Solution {public: string removeDuplicates(string S) { string stk; for (char c : S) if (!stk.empty() && stk.back() == c) stk.pop_back(); else stk.push_back(c); return stk; }};