Top walkers with ties

Write codeEasy15 min

Your task

A weekend step challenge for a hospital charity hands out prizes to the top k walkers, and the rules never break a tie at the cutoff: anyone who matched the last prize winning total wins as well, so the prize list can run longer than k. names holds the walkers and steps holds the total each one logged, one entry per walker, in the same order. Return the winners ordered by steps from high to low. Walkers on the same total are listed by name in plain text order, where every capital letter sorts ahead of every lowercase letter. Return an empty list when k is zero or below, and every walker when k is at least as large as the field.

Examples

prize_cutoff_names(names: list[str], steps: list[int], k: int) -> list[str]
Example 1
Inputprize_cutoff_names(["Nadia", "Owen", "Priya", "Quinn"], [9100, 12400, 9100, 7300], 2)
Output["Owen", "Nadia", "Priya"]
Example 2
Inputprize_cutoff_names(["Rosa", "Sam", "Tomas"], [5000, 5000, 5000], 1)
Output["Rosa", "Sam", "Tomas"]
Example 3
Inputprize_cutoff_names(["Uma", "Vic"], [800, 1500], 5)
Output["Vic", "Uma"]