Skip to content

Commit 0343dfd

Browse files
authored
Create Count Days Without Meetings.java
1 parent f09b6a6 commit 0343dfd

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+
class Solution {
2+
public int countDays(int days, int[][] meetings) {
3+
Arrays.sort(meetings, (o1, o2) -> {
4+
int c = Integer.compare(o1[0], o2[0]);
5+
if (c != 0) {
6+
return c;
7+
}
8+
return Integer.compare(o2[1], o1[1]);
9+
});
10+
int meetingDays = 0;
11+
int idx = 0;
12+
while (idx < meetings.length) {
13+
int start = meetings[idx][0];
14+
int end = meetings[idx][1];
15+
idx++;
16+
while (idx < meetings.length && meetings[idx][0] <= end) {
17+
end = Math.max(end, meetings[idx][1]);
18+
idx++;
19+
}
20+
meetingDays += (end - start + 1);
21+
}
22+
return days - meetingDays;
23+
}
24+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy