2025-08-19 17:23:46 +0000 UTC

Determine if Two Events Have Conflict

Code

class Solution:
    def haveConflict(self, event1: List[str], event2: List[str]) -> bool:
        def parse(clock: str) -> int:
            hh, mm = clock[:2], clock[2:]
            return hh * 60 + mm
        start1, end1 = map(parse, event1)
        start2, end2 = map(parse, event2)
        if start1 == start2:
            return True
        if start1 > start2:
            return start1 <= end2
        return end1 >= start2