Code RoomFirst log line with keyword
EasyPrep Room Coding #493

First log line with keyword

CodingAlgorithms & data structuresEntry–Mid~11 min

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.

0:00 of about 11 min
InputExpectedGot
[["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"]"2026-07-01T10:00:03"not run yetsample