728x90
문제 : https://leetcode.com/problems/rank-transform-of-an-array/description/
난이도 : Easy
풀이
class Solution:
def arrayRankTransform(self, arr: List[int]) -> List[int]:
ans = []
sortedArr = sorted(arr)
d = {}
rank = 1
for i in sortedArr:
if i not in d:
d[i] = rank
rank += 1
for i in arr:
ans.append(d[i])
return ans
728x90