Comment Moderation Holds
EasyHash Map · TikTok
You are given a chronological list of moderation events. Each event is [comment_id, video_id, action], where action is one of:
"create": posts a new comment onvideo_id. It starts visible."hold": hides the comment (it is kept but not shown)."approve": makes the comment visible again."remove": deletes the comment permanently.
Rules for messy input:
- A
"create"for acomment_idthat already exists (even a removed one) is ignored. "hold","approve"and"remove"for a comment that has not been created yet, or that was already removed, are ignored."hold"on an already hidden comment and"approve"on an already visible comment change nothing.- All events about the same comment carry that comment's
video_id.
Return [video_id, visible_count] for every video that had at least one comment created, sorted by video_id ascending. Include videos whose count ends at 0.
Example 1
- Input:
- events = [["c1", "v2", "create"], ["c2", "v2", "create"], ["c3", "v1", "create"], ["c2", "v2", "hold"], ["c3", "v1", "remove"], ["c3", "v1", "approve"]]
- Output:
- [["v1", 0], ["v2", 1]]
- Explanation
- On
v2,c1stays visible andc2is held, sov2shows 1. Onv1,c3is removed, and the later approve is ignored because removal is permanent, sov1shows 0 but is still reported.
Example 2
- Input:
- events = [["a", "v9", "hold"], ["a", "v9", "create"], ["a", "v9", "hold"], ["a", "v9", "approve"]]
- Output:
- [["v9", 1]]
- Explanation
- The first hold arrives before
aexists and is ignored. After creation,ais held and then approved, so it ends visible.
Example 3
- Input:
- events = [["x", "v1", "create"], ["x", "v1", "remove"], ["x", "v1", "create"]]
- Output:
- [["v1", 0]]
- Explanation
- Once
xis removed, its id is used up, so the second create is ignored andv1ends with 0 visible comments.
Constraints
0 <= events.length <= 10^5comment_idandvideo_idare non-empty stringsactionis one of"create","hold","approve","remove"- All events for one
comment_iduse the samevideo_id