Runtime 17ms, memory 40MB each line explained in c++. beated 90%+ users in both TC and SC.
Intuitionsimulate the process for each event. keep trace of offline users using offline array.Approach

sort the event in the time assending manner with two dif
# Intuition
simulate the process for each event. keep trace of offline users using offline array.

# Approach
1. sort the event in the time assending manner with two different event s occure on the same time (OFFLINE and MESSAGE). then put OFFLINE event before MESSAGE event, as it was told in description.

2. OFFLINE EVENT:- map offline_user_id event with timestamp.
3. MESSAGE EVENT :-
    - ALL :- increase all users mention by 1.
    - id :- first extract user id from id array them increase mention of user by 1. do this while iterating the id string.
    - HERE :- iterate over all the users and check , if user is maped with timestamp and user is not onlined yet( by checking that 60 time unit have not happened from when user was sleeped), then don't increase user mention.
    otherwise increase the user mention.

# Complexity
- Time complexity: O(N*countMentions)

- Space complexity: O(N)

# Code
```cpp []
auto compare = [](vector<string>& event1, vector<string>& event2) {
    int time1 = stoi(event1[1]), time2 = stoi(event2[1]);
    if (time1 != time2)
        return time1 < time2;
    else if (event1[0] != event2[0])
        return event1[0] == "OFFLINE";
    return false;
};

class Solution {
public:
    vector<int> countMentions(int numberOfUsers,
                              vector<vector<string>>& events) {
        sort(events.begin(), events.end(), compare); // 1. sorting the events
        vector<int> users(numberOfUsers, 0);
        vector<int> offline(numberOfUsers, -70); // -70 mean user is online. here value other than -70 will be timstamp.

        for (vector<string>& event : events) { // iterating over all the events
            if (event[0] == "OFFLINE") { // for offline event
                offline[ stoi(event[2]) ] = stoi(event[1]); // map user_offline_id with timestamp.
                continue;
            }
            if (event[2] == "ALL") { // for MESSAGE ALL event increase all users mention by 1.
                for (int& user : users)
                    user++;
            } else if (event[2][0] == 'i') { // for MESSAGEW ID_STRING event i am skkiping first 2 id and extracting number after id then i++ for skipping the space after the number
                int len = event[2].length(); // length of the ID_STRING
                for (int i = 2; i < len; i += 2) { // skkiping over the id substring. 
                    int num = 0; // for storing extracted number 
                    while (i < len &&  event[2][i]!= ' '){ 
                        num = (num * 10) + (event[2][i] - '0');// accumilating number from left to right manner
                        ++i;
                    }
                    // now num is containing user id.
                    users[num]++; // increasing mention for user with id == num.
                    ++i;// skipping over the space.
                }
            } else { // for MESSSAGE HERE event
            int time = stoi(event[1]); // storing current message timestamp in time.
            for (int i = 0; i < numberOfUsers; i++) { // iterating over each user.
                if ( offline[i] != -70 && offline[i]+60 > time ) // if user is offline skip him.
                    continue;

                offline[i] = -70;
                users[i]++; // otherwise increase mention of user by 1.
            }
            }

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