Untitled
unknown
plain_text
a year ago
693 B
5
Indexable
class Solution {
public boolean haveConflict(String[] event1, String[] event2) {
// Convert event times to minutes
int start1 = convertToMinutes(event1[0]);
int end1 = convertToMinutes(event1[1]);
int start2 = convertToMinutes(event2[0]);
int end2 = convertToMinutes(event2[1]);
// Check for overlap
return ((start1 <= end2) && (start2 <= end1));
}
private int convertToMinutes(String time) {
String[] parts = time.split(":");
int hours = Integer.parseInt(parts[0]);
int minutes = Integer.parseInt(parts[1]);
return hours * 60 + minutes; // Convert to total minutes
}
}Editor is loading...
Leave a Comment