Skip to content

Latest commit

 

History

History
63 lines (49 loc) · 2 KB

_2191. Sort the Jumbled Numbers.md

File metadata and controls

63 lines (49 loc) · 2 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : July 24, 2024

Last updated : July 24, 2024


Related Topics : Array, Sorting

Acceptance Rate : 60.06 %


Solutions

Python

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]