1331. Rank Transform of an Array
Easy
Given an array of integers arr
, replace each element with its rank.
The rank represents how large the element is. The rank has the following rules:
Rank is an integer starting from 1.
The larger the element, the larger the rank. If two elements are equal, their rank must be the same.
Rank should be as small as possible.
Example 1:
Example 2:
Example 3:
Constraints:
0 <= arr.length <= 105
-109 <= arr[i] <= 109
解題
Runtime: 73 ms, faster than 90.48%
Memory Usage: 13.2 MB, less than 21.43%
Last updated