-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_155651.java
More file actions
39 lines (38 loc) · 1.15 KB
/
_155651.java
File metadata and controls
39 lines (38 loc) · 1.15 KB
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
import java.util.*;
class Solution {
public int solution(String[][] book_time) {
inputArrayList(book_time);
Collections.sort(Arr);
// System.out.println(Arr);
for(int e : Arr){
for(int i=0; i<1000; i++){
if(times[i] <= getStartTime(e)){
times[i] = getEndTime(e) + 10;
break;
}
}
}
int cnt = 0;
for(; cnt<1000 && times[cnt]>0; cnt++);
return cnt;
}
static ArrayList<Integer> Arr = new ArrayList<>();
static int[] times = new int[1000];
public static void inputArrayList(String[][] arr){
for(String[] e : arr){
Arr.add(intValueOfTime(e[0]) * 10000 + intValueOfTime(e[1]));
}
}
public static int intValueOfTime(String str){
StringTokenizer st = new StringTokenizer(str,":");
int H = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
return H*60 + M;
}
public static int getStartTime(int n){
return n/10000;
}
public static int getEndTime(int n){
return n%10000;
}
}