Problem 307080 · easy · Level 03 Linear Management & Searching

Leaderboard Ordering

sorting · tuples · multi-key sort

A game keeps one record per player as a tuple (name, score, attempts). Return the list of player names in leaderboard order:

  1. higher score first,
  2. among equal scores, fewer attempts first,
  3. among equal scores and attempts, name in ascending alphabetical order.

Examples

Input:  players = [("ana", 90, 3), ("bo", 95, 5), ("cy", 90, 2), ("di", 95, 5)]
Output: ["bo", "di", "cy", "ana"]
Explanation: bo and di both have 95 points with 5 attempts, so they are ordered by name.
             cy beats ana because both have 90 points but cy needed fewer attempts.

Constraints

  • 0 <= len(players) <= 10**5
  • Names are non-empty lowercase strings; scores and attempts are non-negative integers.
  • Target complexity: O(n log n).

Goals

  • Build a sort key that mixes descending and ascending fields
  • Use negation to flip the direction of a numeric field
  • Extract one field from sorted records
Starting Python…