2191. Sort the Jumbled Numbers
All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : July 24, 2024
Last updated : July 24, 2024
Related Topics : Array, Sorting
Acceptance Rate : 60.06 %
class Solution:
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
return [
z[0] for z in
sorted(
zip(
nums,
[int(''.join([str(mapping[int(c)]) for c in str(x)])) for x in nums],
range(len(nums))
),
key=lambda y: (y[1], y[2]))
]
class Solution:
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
return [z[0] for z in sorted(zip(nums, [int(''.join([str(mapping[int(c)]) for c in str(x)])) for x in nums], range(len(nums))), key=lambda y: (y[1], y[2]))]
class Solution:
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
ref = [int(''.join([str(mapping[int(c)])
for c in str(x)]))
for x in nums]
temp = sorted(zip(nums, ref, range(len(nums))),
key=lambda y: (y[1], y[2]))
return [x[0] for x in temp]