Problem 1003 · Medium

Check If Word Is Valid After Substitutions

Push letters onto a stack and delete every abc that forms on top; the word is valid when the stack empties.

Open the interactive visualisation