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

Question

An API gateway access log has one line per request: "<timestamp> <method> <path> <status>", where status is a three-digit HTTP code like 200 or 503. For a traffic summary, group codes into classes by their first digit: "2xx", "3xx", "4xx", "5xx", and so on. Return a dictionary mapping each class that occurs in the log to its request count. Classes with no requests must be absent, and an empty log returns an empty dictionary.

Implement
status_class_counts(lines: list[str]) → dict[str,int]
Examples
in[["t1 GET /home 200","t2 GET /missing 404","t3 POST /pay 500","t4 GET /home 204"]]out{"2xx":2,"4xx":1,"5xx":1}
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.