← 返回 amazon 的题目列表Longest Happy String
类型:online_judge
Given a string consisting of 'a', 'b', and 'c', return the longest possible string that does not contain "aaa", "bbb", or "ccc".
Input:
Integers a, b, and c representing the quantity of 'a', 'b', and 'c' characters respectively, where 0 <= a, b, c <= 100.
Output:
The longest possible string that does not contain "aaa", "bbb", or "ccc".
Example:
Input: a = 1, b = 1, c = 7 Output: "ccaccbcc"
You must always use the character with the highest remaining count each time, but the total string length cannot exceed a + b + c.
Example
Input
1, 1, 7