#C9090. Filter Logs Within Time Range
Filter Logs Within Time Range
Filter Logs Within Time Range
You are given a series of log entries, where each entry starts with a timestamp followed by a message. The timestamp is in the format \(YYYY\text{-}MM\text{-}DD\ HH:MM:SS\). Your task is to filter out the log messages that occurred between a given start and end timestamp (inclusive). This problem tests your ability to perform string manipulation and simple conditional checks based on lexicographical ordering of timestamps.
Note: The timestamps can be compared as strings because the given format guarantees that lexicographical order is equivalent to chronological order.
inputFormat
The input is provided via standard input (stdin) and follows this format:
- The first line contains an integer \(n\) which denotes the number of log entries.
- The next \(n\) lines each contain a log entry. Each log entry is formatted as:
YYYY-MM-DD HH:MM:SS Message
. - The following line contains the start timestamp in the format:
YYYY-MM-DD HH:MM:SS
. - The next line contains the end timestamp in the same format.
There is no extra whitespace in the input.
outputFormat
Output the filtered log messages to standard output (stdout). Each message that occurs between the start and end timestamps (inclusive) should be printed on a new line. If there are no messages in the specified time range, output nothing.
## sample6
2023-01-01 10:00:00 System start
2023-01-01 10:05:00 User login
2023-01-01 10:15:00 File upload
2023-01-01 10:20:00 Network error
2023-01-01 10:25:00 System check
2023-01-01 10:30:00 User logout
2023-01-01 10:05:00
2023-01-01 10:25:00
User login
File upload
Network error
System check
</p>