package leetcode;

/**
 * https://leetcode.com/problems/my-calendar-i/
 */
public class Problem729 {
    private static class MyCalendar {

        public MyCalendar() {

        }

        public boolean book(int start, int end) {
            // TODO
            return false;
        }
    }

    public static void main(String[] args) {
        MyCalendar calendar = new MyCalendar();
        calendar.book(10, 20); // returns true
        calendar.book(15, 25); // returns false
        calendar.book(20, 30); // returns true
    }
}

package leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * https://leetcode.com/problems/my-calendar-i/
 */
public class Problem729 {
    private static class MyCalendar {
        private final List<int[]> list = new ArrayList<>();

        public MyCalendar() {
        }

        public boolean book(int start, int end) {
            for (int[] i : list) {
                if (i[0] < end && start < i[1]) {
                    return false;
                }
            }
            list.add(new int[]{start, end});
            return true;
        }
    }
}

Solve problem 729