We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fd23399 commit e24c5a6Copy full SHA for e24c5a6
Medium/Finding the Users Active Minutes.java
@@ -0,0 +1,24 @@
1
+class Solution {
2
+ public int[] findingUsersActiveMinutes(int[][] logs, int k) {
3
+ Map<Integer, Set<Integer>> map = new HashMap<>();
4
+ List<Set<Integer>> setList = new ArrayList<>();
5
+ for (int i = 0; i < k; i++) {
6
+ setList.add(new HashSet<>());
7
+ }
8
+ for (int[] log : logs) {
9
+ map.computeIfAbsent(log[0], j -> new HashSet<>()).add(log[1]);
10
+ int currActiveTime = map.get(log[0]).size();
11
+ if (currActiveTime <= k) {
12
+ setList.get(currActiveTime - 1).add(log[0]);
13
+ if (currActiveTime != 1) {
14
+ setList.get(currActiveTime - 2).remove(log[0]);
15
16
17
18
+ int[] ans = new int[k];
19
20
+ ans[i] = setList.get(i).size();
21
22
+ return ans;
23
24
+}
0 commit comments