A Tedious but Straightforward Solution
IntuitionThe key is to get an understanding of the scope.ApproachThink about several corner cases. Take care of some type conversion.Complexity
Time complexity:
# Intuition
The key is to get an understanding of the scope.

# Approach
Think about several corner cases. Take care of some type conversion.

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

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

# Code
```javascript []
/**
 * @param {number} numberOfUsers
 * @param {string[][]} events
 * @return {number[]}
 */
var countMentions = function(numberOfUsers, events) {
    var mentions = [];
    var onlineList = [];
    for (var i = 0; i < numberOfUsers; i++) {
        mentions.push(0);
        onlineList.push(i);
    }
    events.sort(function(a, b) {
      if (a[1] == b[1]) {
        if (a[0] == 'OFFLINE') return -1;
      }
      return a[1] - b[1]; 
    });

    var online = new Set(onlineList);
    var offline = new Set();
    var timestamps = {};
    events.forEach(event => {
        Object.keys(timestamps).forEach(id => {
            var timestamp = timestamps[id];
            if (id >= 0 && timestamp <= event[1]) {
                offline.delete(parseInt(id));
                online.add(parseInt(id));
            }
        });
     
        if (event[0] == 'OFFLINE') {
            timestamp = parseInt(event[1]) + 60;
            id = parseInt(event[2]);
            timestamps[id] = timestamp;
            offline.add(parseInt(event[2]));
            online.delete(parseInt(event[2]));
        }
        else if (event[0] == 'MESSAGE') {
            if (event[2] == 'ALL') {
                for (var i = 0; i < numberOfUsers; i++) {
                    mentions[i]++;
                }
            }
            else if (event[2] == 'HERE') {
                online.forEach(item => {
                    mentions[item] += 1;
                });
            }
            else {
                ids = event[2].split(' ').map(id => id.replace('id', ''));
                ids.forEach(id => {
                    mentions[parseInt(id)] += 1;
                });
            }
        }
    });
    return mentions;
};
```
['JavaScript']