Tap here to switch tabs
Problem
Submissions

Problem: Relative Ranks

med
30 min
Try to solve the Relative Ranks problem.

Statement

You are given an integer array score of size n, where score[i] represents the score of the iextthi^{ ext{th}} athlete in a competition. All scores are guaranteed to be unique.

The athletes are awarded ranks based on their scores, where the athlete with the highest score receives the 1extst1^{ ext{st}} place rank, the athlete with the second highest score receives the 2extnd2^{ ext{nd}} place rank, and so on.

The placement ranks are decided as follows:

  • The 1extst1^{ ext{st}} place athlete is awarded "Gold Medal".

  • The 2extnd2^{ ext{nd}} place athlete is awarded "Silver Medal".

  • The 3extrd3^{ ext{rd}} place athlete is awarded "Bronze Medal".

  • For the 4extth4^{ ext{th}} place to the nextthn^{ ext{th}} place athlete, their rank is their placement number represented as a string (i.e., "$x$" for the xextthx^{ ext{th}} place).

Return an array answer of size n where answer[i] is the rank of the iextthi^{ ext{th}} athlete.

Constraints:

  • n == score.length

  • 1≤1 \leq n ≤104\leq 10^4

  • 0≤0 \leq score[i] ≤106\leq 10^6

  • All the values in score are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Relative Ranks

med
30 min
Try to solve the Relative Ranks problem.

Statement

You are given an integer array score of size n, where score[i] represents the score of the iextthi^{ ext{th}} athlete in a competition. All scores are guaranteed to be unique.

The athletes are awarded ranks based on their scores, where the athlete with the highest score receives the 1extst1^{ ext{st}} place rank, the athlete with the second highest score receives the 2extnd2^{ ext{nd}} place rank, and so on.

The placement ranks are decided as follows:

  • The 1extst1^{ ext{st}} place athlete is awarded "Gold Medal".

  • The 2extnd2^{ ext{nd}} place athlete is awarded "Silver Medal".

  • The 3extrd3^{ ext{rd}} place athlete is awarded "Bronze Medal".

  • For the 4extth4^{ ext{th}} place to the nextthn^{ ext{th}} place athlete, their rank is their placement number represented as a string (i.e., "$x$" for the xextthx^{ ext{th}} place).

Return an array answer of size n where answer[i] is the rank of the iextthi^{ ext{th}} athlete.

Constraints:

  • n == score.length

  • 1≤1 \leq n ≤104\leq 10^4

  • 0≤0 \leq score[i] ≤106\leq 10^6

  • All the values in score are unique.