Skip to content

Commit 90ee18e

Browse files
authored
Create 1817-finding-the-users-active-minutes.js
1 parent 1e5585a commit 90ee18e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @param {number[][]} logs
3+
* @param {number} k
4+
* @return {number[]}
5+
*/
6+
const findingUsersActiveMinutes = function(logs, k) {
7+
const hash = {}, map = {}
8+
logs.forEach(l => {
9+
const [id, mi] = l
10+
if(hash[mi] == null) hash[mi] = new Set()
11+
if(map[id] == null) map[id] = new Set()
12+
hash[mi].add(id)
13+
map[id].add(mi)
14+
})
15+
16+
const res = Array(k).fill(0)
17+
Object.keys(map).forEach(k => {
18+
const num = map[k].size
19+
res[num - 1]++
20+
})
21+
22+
return res
23+
24+
};

0 commit comments

Comments
 (0)