Dense Ranks Preserving Value Order and Equality. Replace each value by its smallest possible positive rank: equal values share a rank, and a larger value must have a larger rank.
### Problem
Replace each value by its smallest possible positive rank: equal values share a rank, and a larger value must have a larger rank. Return ranks in the original position order. The empty array is allowed.
```cpp
class Solution {
public:
vector<int> arrayRankTransform(vector<int>& arr);
};
```
### Examples
**Example 1:**
```text
Input: arr = [7,-2,7,0]
Output: [3,1,3,2]
Explanation: The distinct sorted values-2,0,7 receive ranks1,2,3.
```
**Example 2:**
```text
Input: arr = []
Output: []
Explanation: There are no positions to rank.
```
### Constraints
- Array length is between 0 and 100000.
- Each original value is an integer in `[-1000000000,1000000000]`.
### Contract considerations
Keep the vector-reference callable; the reference replaces and returns that input array.
```hint Read the boundary condition
Check equal values, negative values, and an empty input. Ranks must remain in the original position order and be as small as permitted.
```
### Boundary reminders
Keep the vector-reference callable; the reference replaces and returns that input array.
Overview: Dense Ranks Preserving Value Order and Equality. Replace each value by its smallest possible positive rank: equal values share a rank, and a larger value must have a larger rank.
Replace each value by its smallest possible positive rank: equal values share a rank, and a larger value must have a larger rank. Return ranks in the original position order. The empty array is allowed.
class Solution {
public:
vector<int> arrayRankTransform(vector<int>& arr);
};