101 Logo
onenoughtone

Problem Statement

Schedule Validator

You're a busy professional trying to determine if you can attend all the meetings in your calendar for the day.

Given an array of meeting time intervals where each interval consists of a start and end time [start, end], determine if it's possible for you to attend all meetings without any conflicts.

A conflict occurs when two meetings overlap, meaning one meeting starts before another meeting ends.

Examples

Example 1:

Input: intervals = [[0,30],[5,10],[15,20]]
Output: false
Explanation: The first meeting [0,30] overlaps with both the second meeting [5,10] and the third meeting [15,20], so you cannot attend all meetings.

Example 2:

Input: intervals = [[7,10],[2,4]]
Output: true
Explanation: The first meeting is from 7 to 10, and the second meeting is from 2 to 4. Since they don't overlap, you can attend both meetings.

Constraints

  • 0 <= intervals.length <= 10^4
  • intervals[i].length == 2
  • 0 <= start < end <= 10^6

Problem Breakdown

To solve this problem, we need to:

  1. Two meetings conflict if one starts before the other ends
  2. Sorting the intervals by start time makes it easier to check for conflicts
  3. After sorting, we only need to compare adjacent intervals
  4. If any pair of adjacent intervals overlap, it's impossible to attend all meetings
  5. This problem is a simple application of interval scheduling
ProblemSolutionCode
101 Logo
onenoughtone