Longest String Without AAA or BBB
There are two-letter strings, "AA", "AB" and "BB", which appear AA, AB and BB times respectively. The task is to join some of these strings to create the longest possible string which does not contain "AAA" or "BBB". For example, having AA = 5, AB = 0 and BB = 2, it is possible to join five strings by taking both of the "BB" strings and three of the "AA" strings. Then they can be joined into "AA-BB-AA-BB-AA" = "AABBAABBA". Note that it is not possible to add another "AA" string as the result would then contain "AAA".
Given three integers AA, AB and BB, returns the longest string that can be created according to the rules described above. If there is more than one possible answer, the function may return any of them.
1Example 1
2Example 2
3Example 3
4Example 4
Constraints
Limits and guarantees your solution can rely on.
- AA, AB and BB are integers within the range [0..10].
- The resulting string will not be empty.