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