Problem 2696 · Easy

Minimum String Length After Removing Substrings

Push letters on a stack and pop whenever the top two form AB or CD, which is the only removal that matters.

Open the interactive visualisation