Skip to content

Commit 019cf08

Browse files
committed
https://leetcode.cn/problems/finding-the-users-active-minutes
1 parent 4bdee45 commit 019cf08

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ Step 2. Add the dependency
4949

5050
<summary>展开查看</summary>
5151

52+
https://leetcode.cn/problems/finding-the-users-active-minutes
53+
5254
https://leetcode.cn/problems/strong-password-checker-ii/
5355

5456
https://leetcode.cn/problems/finding-mk-average
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function findingUsersActiveMinutes(logs: number[][], k: number): number[] {
2+
const activeMinutes = new Map<number, Set<number>>();
3+
for (const [id, time] of logs) {
4+
if (!activeMinutes.has(id)) {
5+
activeMinutes.set(id, new Set());
6+
}
7+
activeMinutes.get(id)?.add(time);
8+
}
9+
const answer: number[] = new Array(k).fill(0);
10+
for (const minutes of activeMinutes.values()) {
11+
const activeCount = minutes.size;
12+
answer[activeCount - 1]++;
13+
}
14+
return answer;
15+
}
16+
export default findingUsersActiveMinutes;

0 commit comments

Comments
 (0)