Top walkers with ties
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.
prize_cutoff_names(names: list[str], steps: list[int], k: int) → list[str][["Nadia","Owen","Priya","Quinn"],[9100,12400,9100,7300],2]out["Owen","Nadia","Priya"][["Rosa","Sam","Tomas"],[5000,5000,5000],1]out["Rosa","Sam","Tomas"][["Uma","Vic"],[800,1500],5]out["Vic","Uma"]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["Nadia","Owen","Priya","Quinn"],[9100,12400,9100,7300],2]["Owen","Nadia","Priya"]not run yetsample[["Rosa","Sam","Tomas"],[5000,5000,5000],1]["Rosa","Sam","Tomas"]not run yetsample[["Uma","Vic"],[800,1500],5]["Vic","Uma"]not run yetsample