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 97a452c commit b56d702Copy full SHA for b56d702
meeting-rooms/jaejeong1.java
@@ -0,0 +1,29 @@
1
+import java.util.List;
2
+
3
+// Definition of Interval:
4
+class Interval {
5
+ int start, end;
6
+ Interval(int start, int end) {
7
+ this.start = start;
8
+ this.end = end;
9
+ }
10
+}
11
12
13
+public class Solution {
14
+ /**
15
+ * @param intervals: an array of meeting time intervals
16
+ * @return: if a person could attend all meetings
17
+ */
18
+ public boolean canAttendMeetings(List<Interval> intervals) {
19
+ // Write your code here
20
+ var sortedIntervals = intervals.stream().sorted().toList();
21
22
+ for (int i=0; i<sortedIntervals.size()-1; i++) {
23
+ if (sortedIntervals.get(i).end > sortedIntervals.get(i+1).start) {
24
+ return false;
25
26
27
+ return true;
28
29
0 commit comments