Given an integer array arr, replace each element with its rank when the distinct values of arr are sorted in strictly increasing order.
The rank rules are:
The smallest distinct value has rank
If a value is the
Equal values must receive the same rank.
Return the resulting array of ranks in the same order as arr.
Note: Ranks are assigned based only on the sorted order of distinct values, not on the original indices.
Constraints:
arr.length
arr[i]
Given an integer array arr, replace each element with its rank when the distinct values of arr are sorted in strictly increasing order.
The rank rules are:
The smallest distinct value has rank
If a value is the
Equal values must receive the same rank.
Return the resulting array of ranks in the same order as arr.
Note: Ranks are assigned based only on the sorted order of distinct values, not on the original indices.
Constraints:
arr.length
arr[i]