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 995
995
3110|[ Score of a String] ( ./solutions/3110-score-of-a-string.js ) |Easy|
996
996
3151|[ Special Array I] ( ./solutions/3151-special-array-i.js ) |Easy|
997
997
3160|[ Find the Number of Distinct Colors Among the Balls] ( ./solutions/3160-find-the-number-of-distinct-colors-among-the-balls.js ) |Medium|
998
+ 3169|[ Count Days Without Meetings] ( ./solutions/3169-count-days-without-meetings.js ) |Medium|
998
999
3174|[ Clear Digits] ( ./solutions/3174-clear-digits.js ) |Easy|
999
1000
3191|[ Minimum Operations to Make Binary Array Elements Equal to One I] ( ./solutions/3191-minimum-operations-to-make-binary-array-elements-equal-to-one-i.js ) |Medium|
1000
1001
3208|[ Alternating Groups II] ( ./solutions/3208-alternating-groups-ii.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 3169. Count Days Without Meetings
3
+ * https://leetcode.com/problems/count-days-without-meetings/
4
+ * Difficulty: Medium
5
+ *
6
+ * You are given a positive integer days representing the total number of days an employee is
7
+ * available for work (starting from day 1). You are also given a 2D array meetings of size n
8
+ * where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting
9
+ * i (inclusive).
10
+ *
11
+ * Return the count of days when the employee is available for work but no meetings are scheduled.
12
+ *
13
+ * Note: The meetings may overlap.
14
+ */
15
+
16
+ /**
17
+ * @param {number } days
18
+ * @param {number[][] } meetings
19
+ * @return {number }
20
+ */
21
+ var countDays = function ( days , meetings ) {
22
+ meetings . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] ) ;
23
+
24
+ let result = 0 ;
25
+ let currentEnd = 0 ;
26
+
27
+ for ( const [ start , end ] of meetings ) {
28
+ if ( start > currentEnd + 1 ) {
29
+ result += start - currentEnd - 1 ;
30
+ }
31
+ currentEnd = Math . max ( currentEnd , end ) ;
32
+ }
33
+
34
+ if ( currentEnd < days ) {
35
+ result += days - currentEnd ;
36
+ }
37
+
38
+ return result ;
39
+ } ;
You can’t perform that action at this time.
0 commit comments