Can Attend All Scheduled Meetings
You are given a list of meeting intervals. Determine whether one person can attend every meeting without any two meetings overlapping.
Meeting Representation
Each meeting is represented by a string in the format "start,end", where:
start is the time when the meeting begins.
end is the time when the meeting finishes.
A meeting that starts exactly when another meeting ends is not considered overlapping.
Method Signature
boolean canAttendAllMeetings(List
intervals)
Parameters
intervals: A list of meeting intervals, where each interval is written as "start,end".
Return Value
- Return
true when all meetings can be attended without an overlap.
- Return
false when at least two meetings overlap.
Constraints
intervals is not null.
- Each string contains exactly two comma-separated integers.
- For every meeting,
start < end.
- Meeting start and end times are integers.
- The meetings may be provided in any order.
Examples
Example 1
Method Call: canAttendAllMeetings(intervals = List.of("2,7", "6,9", "12,15"))
Output: false
Explanation: The meetings "2,7" and "6,9" overlap.
Example 2
Method Call: canAttendAllMeetings(intervals = List.of("10,14", "1,5", "6,9"))
Output: true
Explanation: None of the meetings overlap, even though they are not listed in chronological order.
Example 3
Method Call: canAttendAllMeetings(intervals = List.of("3,8", "8,11", "11,16"))
Output: true
Explanation: Each meeting starts exactly when the previous meeting ends, so there is no overlap.
Example 4
Method Call: canAttendAllMeetings(intervals = List.of())
Output: true
Explanation: An empty meeting schedule contains no overlapping meetings.