← 返回 apple 的题目列表Identify Failed Login Attempts and Sort by Frequency
类型:online_judge
Given a system log file, identify all failed login attempt IPs and their corresponding machines. Sort the attempts by the number of failures and output the result.
Input
A series of system logs, each line containing:
Timestamp
Machine name
IP address
Status (success or fail)
Output
A list of IP addresses sorted by the number of failed attempts.
Each IP is associated with its machine name and the number of failed attempts.
Ensure the processing efficiency, as the log file can be very large.
Example
Input
2025-11-19 12:45:00 machine-a 192.168.1.1 fail
2025-11-19 12:46:00 machine-b 192.168.1.2 success
2025-11-19 12:47:00 machine-a 192.168.1.1 fail
2025-11-19 12:48:00 machine-c 192.168.1.3 fail
2025-11-19 12:49:00 machine-b 192.168.1.2 fail
2025-11-19 12:50:00 machine-a 192.168.1.1 fail