好男喔
意外的不太會greedy
當個貪心的人好難
def longestDiverseString(self, a: int, b: int, c: int) -> str:
l = [[a, 'a'], [b, 'b'], [c, 'c']]
ans = ""
while True:
l.sort()
i = 2
if len(ans)>=2 and (ans[-1]==ans[-2]) and (ans[-2]==l[i][1]):
i = 1
if l[i][0] > 0:
ans += l[i][1]
l[i][0] -= 1
else:
break
return ans