Practice Count Mentions Per User
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
All numberOfUsers users begin online. Process events in timestamp order. An OFFLINE event ["OFFLINE", timestamp, id] makes that user offline until timestamp + 60. A MESSAGE event ["MESSAGE", timestamp, mentions] uses either ALL for every user, HERE for currently online users, or space-separated id<number> tokens for explicit users, including offline ones. Count duplicate explicit tokens separately. At a shared timestamp, apply offline changes and automatic returns online before messages. Return the mention total for each user across all messages.
Source: Count Mentions Per User on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
numberOfUsers = 2, events = [["MESSAGE","10","id1 id0"],["OFFLINE","11","0"],["MESSAGE","71","HERE"]]
[2,2]
# Example 2
numberOfUsers = 2, events = [["MESSAGE","10","id1 id0"],["OFFLINE","11","0"],["MESSAGE","12","ALL"]]
[2,2]
# Example 3
numberOfUsers = 2, events = [["OFFLINE","10","0"],["MESSAGE","12","HERE"]]
[0,1]
Constraints
Related LeetCode Problems
Practice more problems similar to Count Mentions Per User.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.