Amazon Online Assessment (OA) - Longest String Without 3 Consecutive Characters

Given A, B, C, find any string of maximum length that can be created such that no 3 consecutive characters are same. There can be at max A 'a', B 'b' and C 'c'.

Examples

Example 1:

Input:A = 1, B = 1, C = 6
Output: ccbccacc

Example 2:

Input:A = 1, B = 2, C = 3
Output: acbcbc

Try it yourself