1405. Longest Happy String
Practice Longest Happy String for free on NudgeCode: Medium, Heap pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
A string is happy if:
- it contains only the letters
'a','b'and'c' - it doesn't contain
"aaa","bbb"or"ccc"(no letter three times in a row) - it has at most
aletters'a', at mostbletters'b'and at mostcletters'c'
Return the longest happy string. If several happy strings have that longest length, return any of them; the expected value is one of them. If only the empty string is happy, return "".
Example
a = 1, b = 1, c = 7 -> "ccaccbcc"
"ccbccacc" is also accepted. No happy string for these counts is longer than 8.
Constraints
- 0 <= a, b, c <= 100
- a + b + c > 0