Skip to content

Commit 1e059b4

Browse files
authored
Create Determine if Two Events Have Conflict.java
1 parent b1bcff1 commit 1e059b4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public boolean haveConflict(String[] event1, String[] event2) {
3+
int minutesEvent1Start = getMinutes(event1[0]);
4+
int minutesEvent1End = getMinutes(event1[1]);
5+
int minutesEvent2Start = getMinutes(event2[0]);
6+
int minutesEvent2End = getMinutes(event2[1]);
7+
return !(minutesEvent1End < minutesEvent2Start || minutesEvent2End < minutesEvent1Start);
8+
}
9+
10+
private static int getMinutes(String time) {
11+
String[] split = time.split(":");
12+
return Integer.parseInt(split[0]) * 60 + Integer.parseInt(split[1]);
13+
}
14+
}

0 commit comments

Comments
 (0)