Code RoomMost frequent error message
EasyPrep Room Coding #513

Most frequent error message

CodingAlgorithms & data structuresEntry–Mid~12 min

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.

0:00 of about 12 min
InputExpectedGot
[["t1 ERROR db timeout","t2 INFO all fine","t3 ERROR db timeout","t4 ERROR cache miss"]]"db timeout"not run yetsample