Problem statement

https://binarysearch.com/problems/Leaderboard/

Solution

Put all values to set and sort it, then create correspondences d and iterate through array.

Complexity

It is O(n log n) for time and O(n) for space.

Code

class Solution:
    def solve(self, nums):
        d = {x: i for i, x in enumerate(sorted(set(nums))[::-1])}
        return [d[x] for x in nums]