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

Question

A CI pipeline emits log lines of the form "<timestamp> <LEVEL> <message>". The on-call engineer wants a quick severity breakdown of a run. Given the lines, return a dictionary mapping each level that actually appears (for example "INFO", "WARN", "ERROR") to the number of lines logged at that level. Levels that never appear must not be keys in the result, and an empty log yields an empty dictionary.

Implement
level_counts(lines: list[str]) → dict[str,int]
Examples
in[["t1 ERROR db down","t2 INFO retrying now","t3 ERROR db down"]]out{"INFO":1,"ERROR":2}
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.