LENGTHY BUT NOT BAD 
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
```cpp []
class Solution {
public:
static bool cmp(vector<string>&a,vector<string>&b)
{
    int atime=stoi(a[1]);
    int btime=stoi(b[1]);
    if(atime==btime)
    {
        if(a[0]=="OFFLINE" && b[0]=="MESSAGE")
        {
           return true;
        }
    }
     return atime<btime;
}
    vector<int> countMentions(int numberOfUsers,
                              vector<vector<string>>& events) {
       vector<int>emit(numberOfUsers,0);
        vector<int> isOnline(numberOfUsers, 1);
        vector<int>lastOfflines(numberOfUsers,-1);
        sort(events.begin(),events.end(),cmp);
        for (auto it : events) {
            string status = it[0];
            string timestamp = it[1];
            string mentioned = it[2];
            for(int i=0;i<lastOfflines.size();i++)
            {
                int time=stoi(timestamp);
                
                if(lastOfflines[i]==-1) continue;
                if(time-lastOfflines[i]>=60)
                {
                    isOnline[i]=1;
                    lastOfflines[i]=-1;
                }
            }
            
            if (status == "MESSAGE") {
                if (mentioned == "HERE") {
                    for (int i = 0; i < numberOfUsers; i++) {
                        if (isOnline[i]) {
                            emit[i]++;
                        }
                    }
                } else if (mentioned == "ALL") {
                    for (int i = 0; i < numberOfUsers; i++) {
                
                            emit[i]++;
                    }

                } else {
                    string id = "";
                    for (int i = 0; i < mentioned.size(); i++) {

                        if (mentioned[i] >= '0' && mentioned[i] <= '9') {
                            id += mentioned[i];
                        } else {
                          
                            if(!id.empty())
                            {
                            int idnum = stoi(id);
                            emit[idnum]++;
                            id = "";
                            }
                        }
                    }
                    int idnum=stoi(id);
                    emit[idnum]++;
                }
            } else {
                if(status=="OFFLINE")
                {
                    int time=stoi(timestamp);
                    int id=stoi(mentioned);
                    isOnline[id]=0;
                    lastOfflines[id]=time;
                }

            }
        }
     return emit;
    }
};
```
['C++']