We consider a string with only alphabets 'a', 'b', 'c'. a string is diverse if no three consecutive letters are the same. meaning that a diverse string cannot contain strings 'aaa', 'bbb', 'ccc'.

write the most efficient python program that given three integers a,b and c, it returns any longest diverse string containing at most a 'a's, b 'b's, and c 'c's. if generating a string is impossible return a blank string.

eg.

given a=6, b=1, c=1

the program may return aabaacaa. note that aacaabaa is also valid.

given a=0, b=1, c=8

the only correct string is ccbcc

Solved
Show answers

Ask an AI advisor a question