1370. Increasing Decreasing String

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1370

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)