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 a28a2d2 commit d50f125Copy full SHA for d50f125
meeting-rooms-ii/sora0319.java
@@ -0,0 +1,33 @@
1
+public class Solution {
2
+ public int minMeetingRooms(int[][] intervals) {
3
+ int n = intervals.length;
4
+ int[] starts = new int[n];
5
+ int[] ends = new int[n];
6
+
7
+ for (int i = 0; i < n; i++) {
8
+ starts[i] = intervals[i][0];
9
+ ends[i] = intervals[i][1];
10
+ }
11
12
+ Arrays.sort(starts);
13
+ Arrays.sort(ends);
14
15
+ int maxCount = 0;
16
+ int count = 0;
17
+ int s = 0;
18
+ int e = 0;
19
20
+ while (s < n) {
21
+ if (starts[s] < ends[e]) {
22
+ count++;
23
+ maxCount = Math.max(maxCount, count);
24
+ s++;
25
+ } else {
26
+ count--;
27
+ e++;
28
29
30
31
+ return maxCount;
32
33
+}
0 commit comments