#C11687. Log Breach Detection
Log Breach Detection
Log Breach Detection
You are given a series of log entries and a threshold. Each log entry contains a timestamp in ISO 8601 format (YYYY-mm-DDTHH:MM:SS) and an IP address. Your task is to detect all IP addresses that have made more than a given number of requests (threshold) within any sliding 60-minute window.
For each IP address, if there exists any one-hour period during which the number of requests exceeds the threshold, then that IP address is considered to have breached the limit. The output should be the list of such IP addresses sorted in lexicographical order, with one IP address per line.
The time difference is calculated using \(60 \times 60\) seconds. Use \(\leq\) when comparing the end of the window.
inputFormat
Input Format:
n threshold log_entry_1 log_entry_2 ... log_entry_n
The first line contains two integers: n
(the number of log entries) and threshold
(the maximum allowed requests within any 60-minute window). Each of the next n
lines contains a log entry with a timestamp and an IP address separated by a space.
The timestamp is in the format \(YYYY\text{-}mm\text{-}DDTHH:MM:SS\).
outputFormat
Output Format:
IP_address_1 IP_address_2 ...
Output each IP address that has breached the request threshold, sorted in lexicographical order, one per line. If no IP address breaches the threshold, output nothing.
## sample7 3
2023-10-14T09:55:00 192.168.1.1
2023-10-14T09:55:30 192.168.1.1
2023-10-14T10:00:00 192.168.1.2
2023-10-14T10:00:30 192.168.1.1
2023-10-14T10:01:00 192.168.1.1
2023-10-14T10:15:00 192.168.1.2
2023-10-14T10:20:00 192.168.1.1
192.168.1.1
</p>