You are given a string `s` of lowercase English letters. A duplicate removal picks two adjacent, equal letters and deletes both. Repeat duplicate removals until no more can be made, and return the final string. The answer is unique.
You are given a string s of lowercase English letters. A duplicate removal picks two adjacent, equal letters and deletes both. Repeat duplicate removals until no more can be made, and return the final string. The answer is unique.
Example 1:
Input: {"s":"abbaca"}
Output: ca
Constraints:
1≤s.length≤105
s consists of lowercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"abbaca"}
s; matching colours = a pair that cancelled
a
0
b
1
b
2
a
3
c
4
a
5
Read the letters left to right. The stack holds the letters kept so far, so its top is the letter just before the next one.