#1047
Remove All Adjacent Duplicates In String
newbie · 250 · lc easy +18 · verified · 72.9% accepted · 7,067 likes · top 83%
Description
Given a string s of lowercase English letters, repeatedly remove any pair of adjacent identical characters until no such pair exists.
Return the final string. It can be shown the result is unique regardless of the order of removals.
Example 1:
Input: s = "abbaca"
Output: "ca"
Explanation:
For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move. The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca".
Example 2:
Input: s = "azxxzy"
Output: "ay"
Code
1
2
3