← 返回 apple 的题目列表Failed Login Log Ranking
类型:qbank
Parse system logs, extract failed login attempts, group by IP and machine, and sort by failed-attempt count.
Examples
Example 1:
Input: logs = [["192.168.1.1","server-a","failed"],["192.168.1.1","server-b","failed"],["192.168.1.1","server-a","success"],["10.0.0.2","server-a","failed"],["10.0.0.2","server-a","failed"],["10.0.0.2","server-c","failed"]]
Output: ["10.0.0.2","192.168.1.1"]
Explanation:
10.0.0.2 had 3 failed attempts and 192.168.1.1 had 2, so 10.0.0.2 comes first.
Example 2:
Input: logs = [["10.0.0.1","server-a","failed"],["10.0.0.2","server-a","failed"]]
Output: ["10.0.0.1","10.0.0.2"]
Explanation:
Both IPs have 1 failed attempt. The tie is broken alphabetically, so 10.0.0.1 comes first.
Example 3:
Input: logs = [["192.168.1.1","server-a","success"]]
Output: []
Explanation:
No failed attempts means no IPs qualify.
Constraints
0 <= logs.length <= 10^5
logs[i].length == 3
status is either "failed" or "success"
ip and machine are non-empty strings of length at most 50