Skip to content

Commit a7b31cc

Browse files
committed
#33 1122
1 parent 433c205 commit a7b31cc

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Array/python/find-the-highest-altitude.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Title : 1732. Find the Highest Altitude
33
Category : Array
4-
URL : https://leetcode.com/problems/maximum-subarray/
4+
URL : https://leetcode.com/problems/find-the-highest-altitude/
55
submission: https://leetcode.com/submissions/detail/448236176/
66
"""
77

Array/python/relative-sort-array.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Title : 1122. Relative Sort Array
3+
Category : Array
4+
URL : https://leetcode.com/problems/relative-sort-array/
5+
submission: https://leetcode.com/submissions/detail/454622350/
6+
"""
7+
8+
from typing import List
9+
10+
# --------------------------------------------------
11+
# Solution:
12+
class Solution:
13+
def relativeSortArray(self, arr1: List[int], arr2: List[int]) -> List[int]:
14+
key = dict().fromkeys(arr2, 0)
15+
temp = []
16+
while arr1:
17+
n = arr1.pop()
18+
if n in key:
19+
key[n] += 1
20+
continue
21+
temp.append(n)
22+
return [el for el, i in key.items() for _ in range(i)] + sorted(temp)
23+

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
[Count Negative Numbers in a Sorted Matrix](https://leetcode.com/problems/count-negative-numbers-in-a-sorted-matrix/) | [Python solution](Array/python/count-negative-numbers-in-a-sorted-matrix.py)
2424
[Matrix Diagonal Sum](https://leetcode.com/problems/matrix-diagonal-sum/) | [Javascript solution](Array/javascript/matrix-diagonal-sum.js)
2525
[Find the Highest Altitude](https://leetcode.com/problems/find-the-highest-altitude/) | [Python solution](Array/python/find-the-highest-altitude.py)
26+
[Relative Sort Array](https://leetcode.com/problems/maximum-subarray/) | [Python solution](Array/python/relative-sort-array.py)
2627

2728

2829
**Linked List**

0 commit comments

Comments
 (0)