2
private List<int[]> bookings;3
private List<int[]> doubleBookings;5
public MyCalendarTwo() {6
bookings = new ArrayList<>();7
doubleBookings = new ArrayList<>();10
public boolean book(int start, int end) {11
for (int[] b : doubleBookings) {12
// condition to check for the overlaping13
if (start < b[1] && end > b[0]) return false;16
for (int[] b : bookings) {17
if (start < b[1] && end > b[0]) {18
doubleBookings.add(new int[] {Math.max(start, b[0]), Math.min(end, b[1])});21
bookings.add(new int[] {start, end});