Skip to content

Commit da1be64

Browse files
committed
Added 2191
1 parent b7bc359 commit da1be64

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@
652652
| 2176 | [Count Equal and Divisible Pairs in an Array](src/2176.count-equal-and-divisible-pairs-in-an-array.py) | Easy | O(N^2) | O(1) | Array | | |
653653
| 2177 | [Count Equal and Divisible Pairs in an Array](src/2177.find-three-consecutive-integers-that-sum-to-a-given-number.py) | Medium | O(1) | O(1) | Math, Binary Search | | |
654654
| 2190 | [Most Frequent Number Following Key In an Array](src/2190.most-frequent-number-following-key-in-an-array.py) | Easy | O(N) | O(N) | Array, Hash Table, Counting | | |
655+
| 2191 | [Sort the Jumbled Numbers](src/2191.sort-the-jumbled-numbers.py) | Medium | O(NlogN) | O(1) | Array, Sorting | | |
655656

656657
## Useful Posts
657658

src/2191.sort-the-jumbled-numbers.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# @lc app=leetcode id=2191 lang=python3
3+
#
4+
# [2191] Sort the Jumbled Numbers
5+
#
6+
7+
# @lc code=start
8+
# TAGS: Array, Sorting
9+
from typing import List
10+
11+
12+
class Solution:
13+
def sortJumbled(self, mapping: List[int], nums: List[int]) -> List[int]:
14+
mapping = {str(i): str(v) for i, v in enumerate(mapping)}
15+
16+
def custom_key(num):
17+
new = []
18+
for d in str(num):
19+
new.append(mapping[d])
20+
return int("".join(new))
21+
return sorted(nums, key=custom_key)
22+
# @lc code=end

0 commit comments

Comments
 (0)