Service recovery time
Your task
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.
Examples
recovery_seconds(lines: list[str]) -> intExample 1
Input
recovery_seconds(["100 up", "160 down", "220 down", "300 up"])Output
140