Search⌘ K
AI Features

Solution: Rank Transform of an Array

C# solution for the Rank Transform of an Array problem using the Sort and Search pattern.

Statement

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 11.
If a value is the kk th smallest distinct value, its rank is kk ...