Skip to main content
Back to problems
#2446
Easy Algorithms

Determine if two events have conflict

Array String
53.1% acceptance
Feb 25, 2026
534
72
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., so me moment is common to both events). * Return true if there is a conflict between two events. Otherwise, return fals e. *

Solution

Rust
Time O(1)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn have_conflict(event1: Vec<String>, event2: Vec<String>) -> bool {
    // conflict iff start1 <= end2 AND start2 <= end1
    event1[0] <= event2[1] && event2[0] <= event1[1]
  }
}