Skip to content

Commit 600aa72

Browse files
authored
Create rank-transform-of-an-array.py
1 parent 38ad0b7 commit 600aa72

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Python/rank-transform-of-an-array.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Time: O(nlogn)
2+
# Space: O(n)
3+
4+
class Solution(object):
5+
def arrayRankTransform(self, arr):
6+
"""
7+
:type arr: List[int]
8+
:rtype: List[int]
9+
"""
10+
return map({x: i+1 for i, x in enumerate(sorted(set(arr)))}.get, arr)

0 commit comments

Comments
 (0)