Skip to content
Decoder

Relative Ranks

Easy

Problem

Athletes finished a race with scores score, where score[i] belongs to athlete i. All scores are different, and a higher score is better.

Give each athlete their placement: first place gets "Gold Medal", second gets "Silver Medal", third gets "Bronze Medal", and everyone from fourth place on gets their place number as a string ("4", "5", ...). Return the answers in the original order of the athletes.

Example 1

Input
score = [5, 4, 3, 2, 1]
Output
["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"]

Example 2

Input
score = [10, 3, 8, 9, 4]
Output
["Gold Medal", "5", "Bronze Medal", "Silver Medal", "4"]

Constraints

  • 1 <= score.length <= 10^4
  • 0 <= score[i] <= 10^6
  • All values in score are unique.

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.