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

Question

An API gateway logs lines shaped like "<timestamp> <LEVEL> <message>", where the timestamp is a sortable string such as "2026-07-01T10:00:03". Given the lines in the order they were written and a keyword, return the timestamp of the first line whose message part — everything after the level token — contains the keyword as a substring. Return "" if no message matches. The timestamp and level tokens are not part of the message.

Implement
first_match_timestamp(lines: list[str], keyword: str) → str
Examples
in[["2026-07-01T10:00:00 INFO cache warm start","2026-07-01T10:00:03 ERROR payment timeout","2026-07-01T10:00:07 ERROR payment timeout"],"timeout"]out"2026-07-01T10:00:03"
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.