We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0fba39c commit 9683348Copy full SHA for 9683348
1256-rank-transform-of-an-array/rank-transform-of-an-array.py
@@ -0,0 +1,12 @@
1
+class Solution:
2
+ def arrayRankTransform(self, arr: List[int]) -> List[int]:
3
+ ranks = {}
4
+ curr_rank = 1
5
+ for ele in sorted(set(arr)):
6
+ ranks[ele] = ranks.get(ele, curr_rank)
7
+ curr_rank += 1
8
+
9
+ ans = []
10
+ for ele in arr:
11
+ ans.append(ranks[ele])
12
+ return ans
0 commit comments