Leetcode 1256 Solution
This article provides solution to leetcode question 1256 (rank-transform-of-an-array)
Access this page by simply typing in "lcs 1256" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/rank-transform-of-an-array
Solution
class Solution:
def arrayRankTransform(self, arr: List[int]) -> List[int]:
arr2 = sorted(list(set(arr)))
m = {v: i for i, v in enumerate(arr2)}
return [m[v] + 1 for v in arr]