Skip to content

Commit f06a915

Browse files
authored
Add files via upload
1 parent af05d28 commit f06a915

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

CanAttendMeetings.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Arrays;
2+
3+
public class CanAttendMeetings {
4+
5+
public static boolean canAttendMeetings(int[][] intervals) {
6+
//Using external comparator to sort intervals with start intervals
7+
Arrays.sort(intervals,(a, b)->a[0]-b[0]);
8+
for(int i=1;i<intervals.length;i++) {
9+
if(intervals[i][0]<intervals[i-1][1]) {
10+
return false;
11+
}
12+
}
13+
return true;
14+
}
15+
16+
public static void main(String[] args) {
17+
int[][] intervals={{0,30},{5,10},{15,20}};
18+
System.out.println("expected false --- output:" +canAttendMeetings(intervals));
19+
}
20+
}

0 commit comments

Comments
 (0)