Logs in incident window
During an incident review you must extract the slice of a web server log that falls inside the incident window. Each line begins with a sortable timestamp string like "2026-07-01T10:00:00" followed by a space and the entry text; comparing timestamps as plain strings gives chronological order. Given the lines (any order is possible) and two timestamps start and end (start <= end), return every line whose timestamp satisfies start <= timestamp <= end, keeping the lines in their original order.
Implement
lines_in_range(lines: list[str], start: str, end: str) → list[str]Examples
in
[["2026-07-01T09:59:00 INFO warmup","2026-07-01T10:00:00 ERROR spike begins","2026-07-01T10:05:00 ERROR still bad","2026-07-01T10:20:00 INFO recovered"],"2026-07-01T10:00:00","2026-07-01T10:10:00"]out["2026-07-01T10:00:00 ERROR spike begins","2026-07-01T10:05:00 ERROR still bad"]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 10 min
solution.py
InputExpectedGot
[["2026-07-01T09:59:00 INFO warmup","2026-07-01T10:00:00 ERROR spike begins","2026-07-01T10:05:00 ERROR still bad","2026-07-01T10:20:00 INFO recovered"],"2026-07-01T10:00:00","2026-07-01T10:10:00"]["2026-07-01T10:00:00 ERROR spike begins","2026-07-01T10:05:00 ERROR still bad"]not run yetsample