---
# System prepended metadata

title: 1817. Finding the Users Active Minutes
tags: [Leetcode, Medium]

---

# 1817. Finding the Users Active Minutes
###### tags: `Leetcode` `Medium`
Link: https://leetcode.com/problems/finding-the-users-active-minutes/description/
## Code
```java=
class Solution {
    public int[] findingUsersActiveMinutes(int[][] logs, int k) {
        int[] ans = new int[k];
        Map<Integer, Set<Integer>> map = new HashMap<>();
        for(int[] log:logs){
            if(!map.containsKey(log[0])) map.put(log[0], new HashSet<>());
            map.get(log[0]).add(log[1]);
        }
        for(int key:map.keySet()){
            if(map.get(key).size()<=k){
                ans[map.get(key).size()-1]++;
            }
        }
        return ans;
    }
}
```