Command Palette
Search for a command to run...
Problem 15.3 · IntervalsEasy
What it teaches: Sort by start and check neighbours: any overlap means one person can't attend everything.
Practise it on judges as “Meeting Rooms”.
The problem
Given meeting times [start, end], can one person attend all of them? A meeting ending at time t doesn't clash with one starting at t.
Example 1
Input: [[0,30],[5,10],[15,20]]
Output: false
Example 2
Input: [[7,10],[2,4]]
Output: true
Constraints
Pattern clues in the wording
These clues point to Merge Intervals: Sort intervals by start; each one either overlaps the last merged interval (extend it) or starts a new one.
Stuck? Take one hint at a time
Solution.java · starterimport java.util.*;
class Solution {
public boolean canAttendMeetings(int[][] intervals) {
return true;
}
}
Write your solution locally or in your editor for now. The in-browser runner (Java first, then Python, C++ and more) will run these tests right here.
Test cases
| # | Input | Expected |
|---|
| 1 | intervals = [[0,30],[5,10],[15,20]] | false |
| 2 | intervals = [[7,10],[2,4]] | true |
+ 1 hidden test the code runner will check