Question
A status probe writes one line per check as "<ts> <status>", where ts is integer Unix seconds (chronological) and status is "up" or "down". Postmortems need time-to-recover: find the FIRST "down" line, then the first "up" line after it, and return the difference in seconds between those two timestamps. If the service never went down, return 0. If it went down and no later "up" line exists, return -1.
recovery_seconds(lines: list[str]) → int[["100 up","160 down","220 down","300 up"]]out140State 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.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.