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 the 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

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro
Favorite (idle)