Code Room
CodingEasycod-g1326
Subject Log processingLevel Entry–Mid~12 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

To triage an incident you want the error message that is flooding the log. Each line is "<timestamp> <LEVEL> <message>", where the message may contain spaces. Considering ONLY lines whose level token is exactly "ERROR", return the most frequent message text (the part after the level). If several messages tie on frequency, return the lexicographically smallest one. If the log contains no ERROR lines at all, return the empty string.

Implement
top_error_message(lines: list[str]) → str
Examples
in[["t1 ERROR db timeout","t2 INFO all fine","t3 ERROR db timeout","t4 ERROR cache miss"]]out"db timeout"
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.