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 a1e93a8 commit 9ee2966Copy full SHA for 9ee2966
meeting-rooms/njngwn.java
@@ -0,0 +1,30 @@
1
+/**
2
+ * Definition of Interval:
3
+ * public class Interval {
4
+ * int start, end;
5
+ * Interval(int start, int end) {
6
+ * this.start = start;
7
+ * this.end = end;
8
+ * }
9
10
+ */
11
+
12
+public class Solution {
13
+ /**
14
+ * @param intervals: an array of meeting time intervals
15
+ * @return: if a person could attend all meetings
16
17
+ public boolean canAttendMeetings(List<Interval> intervals) {
18
+ // Write your code here
19
+ intervals.sort((a, b) -> a.start - b.start); // sort by start time
20
21
+ int prevEndTime = 0;
22
+ for (Interval meeting : intervals) {
23
+ if (meeting.start < prevEndTime) {
24
+ return false;
25
+ }
26
+ prevEndTime = meeting.end;
27
28
+ return true;
29
30
+}
0 commit comments