Meeting Rooms: the idea to remember.
Decide whether one person can attend every meeting; a meeting may begin exactly when another ends.
The core insight
Sort meetings by start and compare each start to the previous end.
Why it works
If any two sorted intervals overlap, the first conflict is visible between adjacent intervals; without adjacent conflicts the whole schedule is compatible.
The mistake to avoid
Use start < previousEnd for a conflict. Equality is allowed.
Commented Java solution
Use java.util.* imports and a surrounding solution class. Tree snippets assume the standard TreeNode definition; linked lists use ListNode and Clone Graph uses a Node with val and neighbors; Copy Random List uses Node with val, next and random. Read the input assumptions above.
boolean canAttendMeetings(int[][] meetings) {
Arrays.sort(meetings, (a, b) -> Integer.compare(a[0], b[0]));
for (int i = 1; i < meetings.length; i++)
if (meetings[i][0] < meetings[i - 1][1]) return false;
return true;
}Make the next connection
Independent revision notes with credited Java references. Not affiliated with LeetCode or the source sheets.