Search
⌘K

Leetcode 984. String Without AAA or BBB

Construct a string of length a+b containing exactly a 'a's and b 'b's that never contains "aaa" or "bbb" (no three identical letters in a row). The core challenge is a greedy placement problem: choose which letter to append at each step so you use up the counts without creating a triple.


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.