All problems

The Wildflower Award Board Skips a Rank After a Tie

Level 2 · node · Correctness · Dense position after tied scores

Scenario

A fictional wildflower photo contest assigns equal scores the same position. The board should increment the position only when the score falls, but it skips the next position after a tie.

Requirements

Given scores already sorted in descending order, return each score's rank. Give equal scores the same rank and the next distinct score the immediately following rank.

Acceptance criteria

  • When every score differs, positions increase one at a time starting at one.
  • The score after a tie for first comes second.
  • Even across several ties, increase the rank only once for each distinct score.
  • An empty score list returns an empty array.