We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c434ea9 commit 2507397Copy full SHA for 2507397
EASY/src/easy/MeetingRooms.java
@@ -0,0 +1,34 @@
1
+package easy;
2
+
3
+import java.util.ArrayList;
4
+import java.util.Collections;
5
+import java.util.Comparator;
6
+import java.util.List;
7
8
+import classes.Interval;
9
10
+public class MeetingRooms {
11
+ public boolean canAttendMeetings(Interval[] intervals) {
12
13
+ List<Interval> list = new ArrayList();
14
+ for(Interval interval : intervals){
15
+ list.add(interval);
16
+ }
17
18
+ Collections.sort(list, new Comparator<Interval>(){
19
20
+ @Override
21
+ public int compare(Interval o1, Interval o2) {
22
+ if(o1.start > o2.start) return 1;
23
+ else return -1;
24
25
26
+ });
27
28
+ for(int i = 0; i < list.size()-1; i++){
29
+ if(list.get(i).end > list.get(i+1).start) return false;
30
31
+ return true;
32
33
34
+}
0 commit comments