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

Question

Your web server writes one log line per event in the format "<timestamp> <LEVEL> <message>", for example "2026-07-01T10:00:00 ERROR auth timeout". The level is always the second space-separated token. Given the log lines in order and a level name such as "ERROR", return how many lines were logged at exactly that level. Match the level token exactly — a line whose message merely mentions the word does not count.

Implement
count_level(lines: list[str], level: str) → int
Examples
in[["2026-07-01T10:00:00 ERROR auth timeout","2026-07-01T10:00:05 INFO user login","2026-07-01T10:00:09 ERROR db connect failed"],"ERROR"]out2
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.