bumpsoo 2024-07-24 21:25:40 +09:00
parent 00995bb067
commit ae6414896d

View file

@ -0,0 +1,18 @@
# https://leetcode.com/problems/sort-the-jumbled-numbers
from typing import List
class Solution:
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
def convert(val: int) -> int:
ret = 0
base = 1
while val >= 10:
ret += mapping[val % 10] * base
base *= 10
val //= 10
ret += mapping[val % 10] * base
return ret
return [
nums[i] for i in sorted(range(len(nums)),
key=lambda i: (convert(nums[i]), i))
]