Search
⌘K

Leetcode 1003. Check If Word Is Valid After Substitutions

Determine whether a string of 'a', 'b', 'c' can be formed from an empty string by repeatedly inserting the substring "abc" (equivalently, whether s can be reduced to empty by repeatedly deleting "abc" substrings). The core challenge is efficiently detecting and removing "abc" patterns (e.g., via an online suffix/stack check) for |s| ≤ 2·10^4.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.