Can Attend All Meetings
At Netflix, our teams often juggle multiple projects and meetings. Ensuring that team members can effectively manage their schedules without conflicts is crucial for productivity. This problem asks you to determine if a person can attend all scheduled meetings given a list of their proposed meeting time intervals.
You are given an array of meeting time intervals, where each interval intervals[i] = [start, end] represents the start and end time of a meeting. Your task is to determine if a person could attend all meetings.
Specifically, you must:
canAttendMeetings that takes an array of intervals as input.true if the person can attend all meetings without any schedule conflicts.false if there is at least one pair of meetings that overlap.Input:
intervals: An array of number[] where each inner array [start, end] represents a meeting's start and end time. start and end are non-negative integers.
Output:
boolean: true if all meetings can be attended without overlap, false otherwise.
[s1, e1] and [s2, e2] are considered to overlap if s1 < e2 and s2 < e1. This means if one meeting ends exactly when another begins (e.g., [1, 5] and [5, 8]), they do not overlap, and the person can attend both. If s1 == s2 and e1 == e2, they are considered overlapping.intervals array is empty or contains only one meeting, there are no overlaps, so the person can attend all meetings.Examples
Example 1
Input:
intervals = [[0,30],[5,10],[15,20]]
Output:
false
Note:
The meeting [0,30] overlaps with [5,10] and [15,20]. A person cannot attend all meetings.
Example 2
Input:
intervals = [[7,10],[2,4]]
Output:
true
Note:
There are no overlapping meetings. The person can attend both.
Example 3
Input:
intervals = [[1,5],[5,8],[9,12]]
Output:
true
Note:
Meetings [1,5] and [5,8] do not overlap as one ends exactly when the other begins. Similarly, [5,8] and [9,12] do not overlap. All meetings can be attended.
Constraints
0 <= intervals.length <= 10^4intervals[i].length == 20 <= start < end <= 10^6start and end times are non-negative integers.Loading editor...