Approach 1: Array as Map

TODO

Approach 3: Sorting

class Solution:
    def findRelativeRanks(self, score: List[int]) -> List[str]:
        n = len(score)
        res = [""] * n
        
        rankLabels = {
            0: "Gold Medal",
            1: "Silver Medal",
            2: "Bronze Medal"
        }
 
        scoreSorted = sorted(zip(score, range(n)), reverse=True)
 
        for j, (_, i) in enumerate(scoreSorted):
            res[i] = rankLabels.get(j, str(j + 1))
        
        return res

Complexity

Time:
Space:

Notes

Other Languages