SORTING NOT NEEDED!
IntuitionNo need to sort! First parse offline queries in one loop. Then parse message queries.ApproachNo need to sort!Complexity

Time complexity:
O(numberOfUse
# Intuition
No need to sort! First parse offline queries in one loop. Then parse message queries.

# Approach
No need to sort! 

# Complexity
- Time complexity:
O(numberOfUsers * events.size())

- Space complexity:
O(n)

# Code
```java []
class Solution {
    public int[] countMentions(int numberOfUsers, List<List<String>> events) {
        int[] res = new int[numberOfUsers];
        HashMap<Integer, HashSet<Integer>> hm = new HashMap<>();
        
        for(List<String> e: events){
            if(e.get(0).equals("OFFLINE")){
                HashSet<Integer> hs = hm.getOrDefault(Integer.parseInt(e.get(1)), new HashSet<>());
                hs.add(Integer.parseInt(e.get(2)));
                hm.put(Integer.parseInt(e.get(1)), hs);
            }
        }
        for(List<String> e: events){
            if(e.get(0).equals("MESSAGE")){
                //System.out.println("hi");
                switch(e.get(2)){
                    case "ALL":
                            for(int i=0; i<numberOfUsers; i++) 
                                res[i]++;
                            break;
                    case "HERE":
                            for(int i=0; i<numberOfUsers; i++) 
                                res[i]++;     
                            int ts = Integer.parseInt(e.get(1));
                            for(int i=ts; i>ts-60; i--){
                                if(hm.containsKey(i)){
                                    for(int x: hm.get(i))
                                        res[x]--;
                                }
                            }         
                            break;
                    default:
                        String[] ids = e.get(2).split(" ");
                        for(String id: ids){
                           res[Integer.parseInt(id.substring(2))]++;
                        }
                    break;

                }
            }
        }
        return res;
    }
}
```
['Java']