Medium · Strings
Longest Happy String
Given three non-negative integers a, b and c, return the longest string made of the letters 'a', 'b' and 'c' that uses at most a 'a's, b 'b's and c 'c's and never has three equal letters in a row; if several strings are longest, return any one of them.
Examples
Example 1
a=1 b=1 c=7Output: "ccaccbcc" (len 8)
Example 2
a=2 b=2 c=1Output: "abbac" (len 5)
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.