image_2022-04-20_00-23-21.png
38.7 KB
#medium
#N1817. Finding the Users Active Minutes
problem link
#solution
#N1817. Finding the Users Active Minutes
problem link
#solution
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){
map.putIfAbsent(log[0], new HashSet<>());
map.get(log[0]).add(log[1]);
}
for(Map.Entry<Integer, Set<Integer>> entry : map.entrySet()){
ans[entry.getValue().size()-1]++;
}
return ans;
}
}👍1