3433. Count Mentions Per User
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def countMentions(self, numberOfUsers: int, events: List[List[str]]) -> List[int]:
        num_users = numberOfUsers
        mentions_tracker = [0] * num_users
        next_online = [0] * num_users
        events.sort(key=lambda event: (int(event[1]), 0 if event[0] == "OFFLINE" else 1))

        for event in events:
            action, timestamp, details = event[0], int(event[1]), event[2]
            if action == "OFFLINE":
                user_id = int(details)
                next_online[user_id] = timestamp + 60
            elif action == "MESSAGE":
                if details == "ALL":
                    recipients = range(num_users)
                elif details == "HERE":
                    recipients = [i for i in range(num_users) if next_online[i] <= timestamp]
                else:
                    recipients = [int(uid[2:]) for uid in details.split()]
                for recipient in recipients:
                    mentions_tracker[recipient] += 1

        return mentions_tracker

```
['Python3']