Skip to content

Commit 435f26a

Browse files
committed
Time: 34 ms (68.03%) | Memory: 16.5 MB (61.09%) - LeetSync
1 parent 7906627 commit 435f26a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def customSortString(self, order: str, s: str) -> str:
3+
start = ""
4+
end = ""
5+
hmap = defaultdict(int)
6+
7+
for i in s:
8+
if i not in order:
9+
end+= i
10+
else:
11+
hmap[i] += 1
12+
13+
for char in order:
14+
start += hmap[char] * char
15+
16+
return start + end

0 commit comments

Comments
 (0)