Longest service uptime run
A probe log has one line per health check: "<ts> <service> <status>", with status "ok" or "error". For each service, look at its own checks in log order and find its longest run of consecutive "ok" results (checks of other services in between do not interrupt a run). Given at least one line, return the service with the longest such run; break ties by the alphabetically smallest service name. A service whose checks are all errors has a longest run of 0 and still participates.
Implement
steadiest_service(lines: list[str]) → strExamples
in
[["t1 api ok","t2 db ok","t3 api ok","t4 api error","t5 db ok","t6 api ok","t7 db ok"]]out"db"What a strong answer looks like
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.
0:00 of about 14 min
solution.py
InputExpectedGot
[["t1 api ok","t2 db ok","t3 api ok","t4 api error","t5 db ok","t6 api ok","t7 db ok"]]"db"not run yetsample