Problem 128178 · easy · Phase 01 Prerequisites & Setup

Fastest Lap of the Race

nested loops · lists · conditionals

racers is a list of [name, laps] where laps is a list of lap times in seconds. Find the single fastest lap of the whole race and return [name, lap_number] with the lap number counted from 1. If several laps share the fastest time, choose the one that appears first (earlier racer in the list; for the same racer, the earlier lap). At least one lap exists.

Examples

Input:  racers = [["ann", [62, 58, 60]], ["ben", [57, 61]]]
Output: ["ben", 1]

Input:  racers = [["cid", [70, 70]], ["dee", [70]]]
Output: ["cid", 1]

Constraints

  • 1 <= len(racers) <= 200, 0 <= len(laps) <= 100, 1 <= lap time <= 10**4

Goals

  • Track the best value and where it was found across nested loops
  • Break ties by keeping the first occurrence
Starting Python…