1370. Increasing Decreasing String
On This Page
class Solution:
def sortString(self, s: str) -> str:
cnt = Counter(s)
cs = ascii_lowercase + ascii_lowercase[::-1]
res = []
while len(res) < len(s):
for c in cs:
if cnt[c]:
res.append(c)
cnt[c] -= 1
return "".join(res)