Most frequent error message
Your task
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.
Examples
top_error_message(lines: list[str]) -> strExample 1
Input
top_error_message(["t1 ERROR db timeout", "t2 INFO all fine", "t3 ERROR db timeout", "t4 ERROR cache miss"])Output
"db timeout"