Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create 2446.Determine_if_two_events_have_conflict.py #3585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 2446.Determine_if_two_events_have_conflict.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def haveConflict(self, event1: List[str], event2: List[str]) -> bool:
def time_to_minutes(time: str) -> int:
"""Convert time in HH:MM format to minutes since midnight."""
hours, minutes = map(int, time.split(':'))
return hours * 60 + minutes

start1, end1 = map(time_to_minutes, event1)
start2, end2 = map(time_to_minutes, event2)

# Check if the events overlap
return not (end1 < start2 or end2 < start1)