Determine if Two Events Have Conflict - Problem
You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where:
event1 = [startTime1, endTime1] and event2 = [startTime2, endTime2].
Event times are valid 24 hours format in the form of HH:MM.
A conflict happens when two events have some non-empty intersection (i.e., some moment is common to both events).
Return true if there is a conflict between two events. Otherwise, return false.
Input & Output
Example 1 — Basic Overlap
$
Input:
event1 = ["01:15", "02:00"], event2 = ["01:30", "03:00"]
›
Output:
true
💡 Note:
Events overlap from 01:30 to 02:00. Since event1 starts at 01:15 (before event2 ends at 03:00) and event2 starts at 01:30 (before event1 ends at 02:00), there is a conflict.
Example 2 — No Overlap
$
Input:
event1 = ["01:00", "02:00"], event2 = ["03:00", "04:00"]
›
Output:
false
💡 Note:
Events do not overlap. Event1 ends at 02:00 before event2 starts at 03:00, so there is no time conflict.
Example 3 — Edge Touch
$
Input:
event1 = ["10:00", "11:00"], event2 = ["11:00", "12:00"]
›
Output:
true
💡 Note:
Events touch at exactly 11:00. Since the problem states events are inclusive, they share the moment 11:00, which counts as a conflict.
Constraints
- event1.length == event2.length == 2
- event1[i] and event2[i] are in HH:MM format
- All event times are valid 24-hour format
Visualization
Tap to expand
Understanding the Visualization
1
Input Events
Two events with start and end times in HH:MM format
2
Overlap Check
Compare if event1 starts before event2 ends AND event2 starts before event1 ends
3
Conflict Result
Return true if both conditions are met (overlap exists)
Key Takeaway
🎯 Key Insight: Two intervals overlap if each starts before the other ends
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code