call(back)
Algorithms & Data Structuresmedium

Escape-Room Leaderboard

Teams attempt an escape room repeatedly. Each attempt reports (team, timeSeconds); a team's standing is its best (lowest) time. Implement:

lb.addResult(team, time)   // record an attempt (keep the team's best)
lb.rank(team)              // 1-indexed rank by best time; ties broken
                           // alphabetically; -1 if the team never played
lb.topK(k)                 // the k best team names, in rank order

Asked at