Skip to main content

Leaderboard

Challenge on lesson: Checkpoint: Collections

Build a leaderboard in Solution: - record Player(String name, int score) with natural order = score DESCENDING, then name ASCENDING (implement Comparable) - static List<String> top(List<Player> players, int n) — the top n names per natural order (duplicates in score allowed, name breaks ties) - static NavigableSet<Player> ranked(Set<Player> players) — a TreeSet using that same natural order. Verify the ordering contract: a TreeSet of the players must iterate highest-score-first, ties alphabetical.

Difficulty: intermediate

Back to lesson: Checkpoint: Collections