
My solution to this problem but some of the test cases were failing.
public float openHoursRatio(TimeRange queryTimeRange, List<TimeRange> openHours) {
float sum = 0;
for (TimeRange range : openHours) {
sum += Float.min(range.end, queryTimeRange.end) - Float.max(queryTimeRange.start, range.start);
}
return sum / (queryTimeRange.end - queryTimeRange.start);
}I need help for this problem.