标签:tst mamicode code bsp src image elf 字符串 mic
1.上升下降字符串
1 class Solution: 2 def sortString(self, s): 3 num = [0] * 26 4 for ch in s: 5 num[ord(ch) - ord(‘a‘)] += 1 6 7 ret = list() 8 while len(ret) < len(s): 9 for i in range(26): 10 if num[i]: 11 ret.append(chr(i + ord(‘a‘))) 12 num[i] -= 1 13 for i in range(25, -1, -1): 14 if num[i]: 15 ret.append(chr(i + ord(‘a‘))) 16 num[i] -= 1 17 18 return "".join(ret)
标签:tst mamicode code bsp src image elf 字符串 mic
原文地址:https://www.cnblogs.com/Yanss/p/14034421.html