In Meta infrastructure systems, engineers often need to summarize large volumes of Scuba-style server logs. Given a list of log lines, return the top 5 most frequent error messages.
A log line is considered an error message only if it starts with the prefix "ERROR: ". The message is the substring after that prefix. Count identical messages together and return up to 5 messages ordered by descending frequency. If two messages have the same frequency, return them in lexicographically ascending order.
Implement a function that takes a list of strings logs and returns a list of strings.
logs, a list of log linesIgnore all non-error log lines.
Example 1
Input: logs = ["INFO: boot", "ERROR: disk full", "ERROR: timeout", "ERROR: disk full"]
Output: ["disk full", "timeout"]
Explanation: Only lines starting with "ERROR: " are counted. "disk full" appears twice and "timeout" appears once.
Example 2
Input: logs = ["ERROR: b", "ERROR: a", "ERROR: b", "ERROR: a", "ERROR: c"]
Output: ["a", "b", "c"]
Explanation: "a" and "b" both appear twice, so lexicographic order breaks the tie.
1 <= len(logs) <= 10^50 <= len(logs[i]) <= 200