← 返回 reddit 的题目列表Process Moderator Audit Logs: Order Moderators by Last Add Time
类型:online_judge
Problem: Process Moderator Logs (Return Moderators Ordered by Last Add Time)
You are given a very large string log containing multiple lines of moderator audit records. Each line describes an operation with comma-separated fields:
<target_mod>,<action>,<actor_mod>,<timestamp>
target_mod: the moderator being acted on (string)
action: either add or remove
actor_mod: the moderator who performed the action (string)
timestamp: an integer timestamp (comparable)
Implement a method that takes the log string and returns a List[str]:
Return the usernames who are currently moderators
Sort them by the timestamp of their most recent add operation in ascending order
If two moderators have the same last-add timestamp, break ties by username lexicographically
I/O
Input: string log with N lines (N >= 0)
Output: List[str]
Constraints
0 <= N <= 2e5
Each line length <= 200
timestamp fits in 64-bit integer
Example
Input:
mod2,add,mod1,100
mod3,add,mod2,101
mod2,remove,mod3,102
mod2,add,mod1,103
Output:
["mod3", "mod2"]
Example
Input
mod2,add,mod1,100
mod3,add,mod2,101
mod2,remove,mod3,102
mod2,add,mod1,103
Output
["mod3", "mod2"]