Problems > Collapse Adjacent Pairs > Editorial

Collapse Adjacent Pairs — Solution & Editorial

Back to the Problem

A stack does this in one pass: push each character, but if it equals the top, pop instead.

Complexity: O(|S|)