Leaderboard
Challenge on lesson: Checkpoint: Collections
CHALLENGE
Difficulty: intermediate+25 XP
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.
Press Submit to check your solution.
Back to lesson: Checkpoint: Collections