Logs in incident window

Write codeEasy10 min

Your task

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.

Examples

lines_in_range(lines: list[str], start: str, end: str) -> list[str]
Example 1
Inputlines_in_range(["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")
Output["2026-07-01T10:00:00 ERROR spike begins", "2026-07-01T10:05:00 ERROR still bad"]