-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDetermineIfTwoEventsHaveConflict.java
39 lines (33 loc) · 1.11 KB
/
DetermineIfTwoEventsHaveConflict.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class Solution {
public boolean haveConflict(String[] event1, String[] event2) {
int num1 = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
for(char c : event1[0].toCharArray()){
if(Character.isDigit(c)){
num1 = 10*num1 + Integer.parseInt(c + "");
}
}
for(char c : event2[0].toCharArray()){
if(Character.isDigit(c)){
num3 = 10*num3 + Integer.parseInt(c + "");
}
}
for(char c : event1[1].toCharArray()){
if(Character.isDigit(c)){
num2 = 10*num2 + Integer.parseInt(c + "");
}
}
for(char c : event2[1].toCharArray()){
if(Character.isDigit(c)){
num4 = 10*num4 + Integer.parseInt(c + "");
}
}
if((num1 < num3 && num2 < num3) || (num1 > num4 && num2 > num4)){
return false;
}else{
return true;
}
}
}