Repeated Adjacent Pair Deletion
Problem statement
Given a string s, repeatedly remove adjacent pairs of equal characters. After a removal, newly adjacent equal characters must also be removed.
Return the unique stable string that remains. The process is equivalent to applying removals from left to right with a stack.
Function
removeAdjacentPairs(s: String) → StringExamples
Example 1
s = "ACCAB"return = "B"Remove CC to get AAB, then remove AA to get B.
Example 2
s = "abbaca"return = "ca"Removing bb creates aa, whose removal leaves ca.
Example 3
s = "abc"return = "abc"No adjacent pair is equal.
Constraints
0 <= s.length <= 200000.scontains ASCII letters.