Code Room
CodingMediumcod-g1308
Subject Log processingLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Each line of a platform log has the form "<timestamp> <LEVEL> <service> <message>". A service's error rate is the number of its ERROR lines divided by its total lines. Given at least one line, return the name of the service with the highest error rate. If several services tie on rate, return the alphabetically smallest name among them. Prefer exact integer arithmetic over floating-point division — rates like 1/3 do not compare cleanly as floats.

Implement
worst_error_service(lines: list[str]) → str
Examples
in[["t1 ERROR auth login failed","t2 INFO auth ok","t3 ERROR billing charge failed","t4 ERROR billing retry failed","t5 INFO search ok"]]out"billing"
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.

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.

Run or narrate your approach, then ask the coach.