Remove All Adjacent Duplicates In String
You are given a string s of lowercase letters. A **duplicate removal** deletes two *adjacent* equal characters.
Repeatedly perform duplicate removals on s until no two adjacent characters are equal, then return the final string. The result is guaranteed to be unique.
Example cases
- one collapsein s = "abbaca"out "ca"Remove "bb" to get "aaca", then "aa" to get "ca".
- cascadein s = "azxxzy"out "ay"Remove "xx" to get "azzy", then the newly adjacent "zz" to get "ay".
- no removalsin s = "abc"out "abc"
Constraints
- 1 <= s.length <= 10^5
- s consists of lowercase English letters.
s =
"abbaca"