[C++/Java/Python] Stack Based Solution - Really Clean & Concise
Idea\n- Use stack st to store non duplicate characters so far.\n- Iterating each character c in string s, if the the top of stack is equal to c then st.pop() el
**Idea**\n- Use stack `st` to store non duplicate characters so far.\n- Iterating each character `c` in string `s`, if the the top of stack is equal to `c` then `st.pop()` else `st.append(c)`.\n\n**Implementation**\n<iframe src="https://leetcode.com/playground/7bHcEq4r/shared" frameBorder="0" width="100%" height="320"></iframe>\n\n**Complexity:**\n- Time: `O(N)`, where `N` is length of string `S`.\n- Space: `O(N-D)`, where `D` is a total length for all duplicates.\n\n**Next step, try yourself to solve this following up questions:**\n* [1209. Remove All Adjacent Duplicates K Letters in String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/)\n\nIf you like this post, please **give it a vote**. Any questions or discussions in this post are welcome! Thanks.
[]