Open Ni-Guvara opened 1 year ago
class Solution {
public int[] findingUsersActiveMinutes(int[][] logs, int k) {
Map<Integer, HashSet<Integer>> map = new HashMap<>();
for(int i = 0; i < logs.length; i++){
// 记录 k,v => 用户, 分钟
if(map.containsKey(logs[i][0])){
HashSet<Integer> set = map.get(logs[i][0]);
set.add(logs[i][1]);
map.put(logs[i][0], set);
}else{
HashSet<Integer> cur = new HashSet<>();
cur.add(logs[i][1]);
map.put(logs[i][0], cur);
}
}
int[] ret = new int[k];
map.forEach((key, value) -> {
ret[value.size() - 1]++;
});
return ret;
}
}