Problem Statement

Pattern:


Solution

public boolean canAttendMeetings(List<Interval> intervals) {
	// Write your code here
	intervals.sort(Comparator.comparingInt(i -> i.end));
	Interval prev = new Interval(-1, -1);
	for(Interval curr : intervals) {
		if(curr.start < prev.end) return false;
		prev = curr;
	}
	return true;
}

Notes

  • if there is any overlap return false
  • else return true