public int solution(String[] lines) {
TimeInfo[] timeInfo = convertTime(lines);
int answer = 0;
for (int i = 0; i < timeInfo.length; i++) {
double area = timeInfo[i].endTime + 1;
int cnt = 1;
for (int j = i + 1; j < timeInfo.length; j++) {
if (timeInfo[j].startTime < area) {
cnt++;
}
}
answer = Math.max(answer, cnt);
}
return answer;
}
private TimeInfo[] convertTime(String[] lines) {
TimeInfo[] timeInfo = new TimeInfo[lines.length];
for (int i = 0; i < lines.length; i++) {
String[] split = lines[i].split(" ");
String[] timeParts = split[1].split(":");
int hour = Integer.parseInt(timeParts[0]);
int minute = Integer.parseInt(timeParts[1]);
double second = Double.parseDouble(timeParts[2]);
double processingTime = Double.parseDouble(split[2].substring(0, split[2].length() - 1));
double totalSeconds = hour * 3600 + minute * 60 + second;
double startTime = totalSeconds - processingTime + 0.001;
double endTime = totalSeconds;
timeInfo[i] = new TimeInfo(startTime, endTime);
}
return timeInfo;
}
private static class TimeInfo {
double startTime;
double endTime;
public TimeInfo(double startTime, double endTime) {
this.startTime = startTime;
this.endTime = endTime;
}
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/17676