Rank Transform of an Array | Leetcode 1331