791. Custom Sort String
On This Page
class Solution:
def customSortString(self, order: str, s: str) -> str:
cnt = Counter(s)
res = []
for c in order:
res.append(c * cnt[c])
cnt[c] = 0
for c, v in cnt.items():
res.append(c * v)
return ''.join(res)