js double queue + diffierence array + lazy update solution
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
```javascript []
/**
 * @param {number} numberOfUsers
 * @param {string[][]} events
 * @return {number[]}
 */
var countMentions = function (numberOfUsers, events) {
    const ans = new Array(numberOfUsers).fill(0)
    events.sort((a, b) => {
        if (+a[1] === (+b[1]) && a[0] !== b[0]) {
            if (a[0] === 'OFFLINE') {
                return -1
            } else {
                return 1
            }
        }
        else {
            return +a[1] - (+b[1])
        }
    })
    const q = []
    const q1 = [0]
    let all = 0
    for (let [a, b, c] of events) {
        b = +b
        while (q.length && q[0][1] <= b) {
            const [id, time] = q.shift()
            ans[id] -= q1[0]
            const x = q1.shift()
            q1[0] += x
        }
        if (a === 'MESSAGE') {
            if (c === 'ALL') {
                all++
            } else if (c === 'HERE') {
                all++
                q1[0]++
                q1[q1.length - 1]--
            } else {
                const memo = c.replaceAll(' ', '').split('id')
                for (let i = 1; i < memo.length; i++) {
                    ans[+memo[i]]++
                }
            }
        } else {
            q.push([+c, (+b + 60)])
            q1.push(0)
        }
    }
    while (q.length) {
        const [id, time] = q.shift()
        ans[id] -= q1[0]
        const x = q1.shift()
        q1[0] += x
    }
    for (let i = 0; i < ans.length; i++) {
        ans[i] += all
    }
    return ans
};
```
['Queue', 'JavaScript']