Trains the technique from
LeetCode 2418Sort the PeopleThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A club keeps its season results in two lists of the same length. names[i] is the name a competitor entered under and scores[i] is the number of points that same competitor finished on, so position i of one list always refers to the same competitor as position i of the other.
Every score in scores is different from every other, so the ranking never needs a tie-break. Two competitors may still have entered under the same name.
Return the names arranged from the highest score down to the lowest.
Example 1
Tomas finished on 100, Ines on 25 and Rhea on 9, so that is the order from highest score to lowest.
Example 2
Alpha's 12 beats zeta's 7, so Alpha comes first. The names themselves play no part in the order.
Example 3
The scores from highest to lowest are 47, 12, 3 and 1, which belong to Baz, Kim, Wu and Ana in that order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def leaderboard(names: list[str], scores: list[int]) -> list[str]:public String[] leaderboard(String[] names, int[] scores)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.