Skip to content

Commit 9683348

Browse files
Time: 234 ms (81.17%) | Memory: 35.8 MB (45.49%) - LeetSync
1 parent 0fba39c commit 9683348

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)