← 返回 reddit 的题目列表Can Moderator A Remove Moderator B Based on Add Order
类型:online_judge
Problem: Determine if Moderator A Can Remove Moderator B
Given the same moderator audit log log (same format as in the previous problem), implement a method to determine whether moderator A is allowed to remove moderator B.
Rule:
Use each moderator's first add timestamp as their join order
Return true if A's first-add timestamp is earlier than B's first-add timestamp; otherwise return false
If either A or B never appears in an add action (i.e., has no first-add time), return false
I/O
Input: log string log, and two strings A, B
Output: boolean
Example
Log:
mod2,add,mod1,100
mod3,add,mod2,101
mod2,remove,mod3,102
mod2,add,mod1,103
canRemove(log, "mod3", "mod2") => false
canRemove(log, "mod2", "mod3") => true
Example
Input
mod2,add,mod1,100
mod3,add,mod2,101
mod2,remove,mod3,102
mod2,add,mod1,103
mod2 mod3
Output
true