728x90
https://leetcode.com/problems/custom-sort-string
class Solution:
def customSortString(self, order: str, s: str) -> str:
result = ''
for i in order:
for j in range(s.count(i)):
result += i
s = s.replace(i, '')
result += s
return result
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 930. Binary Subarrays With Sum (1) | 2024.03.14 |
---|---|
[Leetcode] 2485. Find the Pivot Integer (0) | 2024.03.13 |
[Leetcode] 3074. Apple Redistribution into Boxes (0) | 2024.03.10 |
[Leetcode] 349. Intersection of Two Arrays (0) | 2024.03.10 |
[Leetcode] 2540. Minimum Common Value (0) | 2024.03.09 |