Collapse Adjacent Pairs — Solution & Editorial
A stack does this in one pass: push each character, but if it equals the top, pop instead.
Complexity: O(|S|)
A stack does this in one pass: push each character, but if it equals the top, pop instead.
Complexity: O(|S|)