Skip to content

Commit a932f4d

Browse files
committed
Runtime: 197 ms (Top 36.54%) | Memory: 54.3 MB (Top 59.44%)
1 parent dc5adc7 commit a932f4d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1+
// Runtime: 197 ms (Top 36.54%) | Memory: 54.3 MB (Top 59.44%)
12
class MyCalendarThree {
23

34
TreeMap<Integer, Integer> map;
45
public MyCalendarThree() {
56
map = new TreeMap<>();
67
}
7-
8+
89
public int book(int start, int end) {
910
if(map.isEmpty()){
1011
map.put(start, 1);
1112
map.put(end,-1);
1213
return 1;
1314
}
14-
15-
//upvote if you like the solution
16-
15+
16+
//upvote if you like the solution
17+
1718
map.put(start, map.getOrDefault(start,0)+1);
1819
map.put(end, map.getOrDefault(end,0)-1);
19-
20+
2021
int res = 0;
2122
int sum = 0;
2223
for(Map.Entry<Integer, Integer> e: map.entrySet()){
2324
sum += e.getValue();
2425
res = Math.max(res,sum);
2526
}
26-
27+
2728
return res;
2829
}
29-
}
30+
}

0 commit comments

Comments
 (0)