File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 282
282
1780|[ Check if Number is a Sum of Powers of Three] ( ./1780-check-if-number-is-a-sum-of-powers-of-three.js ) |Medium|
283
283
1791|[ Find Center of Star Graph] ( ./1791-find-center-of-star-graph.js ) |Easy|
284
284
1812|[ Determine Color of a Chessboard Square] ( ./1812-determine-color-of-a-chessboard-square.js ) |Easy|
285
+ 1817|[ Finding the Users Active Minutes] ( ./1817-finding-the-users-active-minutes.js ) |Medium|
285
286
1832|[ Check if the Sentence Is Pangram] ( ./1832-check-if-the-sentence-is-pangram.js ) |Easy|
286
287
1880|[ Check if Word Equals Summation of Two Words] ( ./1880-check-if-word-equals-summation-of-two-words.js ) |Easy|
287
288
1886|[ Determine Whether Matrix Can Be Obtained By Rotation] ( ./1886-determine-whether-matrix-can-be-obtained-by-rotation.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1817. Finding the Users Active Minutes
3
+ * https://leetcode.com/problems/finding-the-users-active-minutes/
4
+ * Difficulty: Medium
5
+ *
6
+ * You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented
7
+ * by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi
8
+ * performed an action at the minute timei.
9
+ *
10
+ * Multiple users can perform actions simultaneously, and a single user can perform multiple actions
11
+ * in the same minute.
12
+ *
13
+ * The user active minutes (UAM) for a given user is defined as the number of unique minutes in which
14
+ * the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions
15
+ * occur during it.
16
+ *
17
+ * You are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j]
18
+ * is the number of users whose UAM equals j.
19
+ *
20
+ * Return the array answer as described above.
21
+ */
22
+
23
+ /**
24
+ * @param {number[][] } logs
25
+ * @param {number } k
26
+ * @return {number[] }
27
+ */
28
+ var findingUsersActiveMinutes = function ( logs , k ) {
29
+ const map = new Map ( ) ;
30
+ logs . forEach ( ( [ id , time ] ) => {
31
+ map . set ( id , map . get ( id ) || new Set ( ) ) ;
32
+ map . get ( id ) . add ( time ) ;
33
+ } ) ;
34
+
35
+ const result = new Array ( k ) . fill ( 0 ) ;
36
+ [ ...map . values ( ) ] . forEach ( ( { size } ) => result [ size - 1 ] ++ ) ;
37
+
38
+ return result ;
39
+ } ;
You can’t perform that action at this time.
0 commit comments