My Calendar III Problem
My Calendar III Problem — ExecCode Hard DSA Practice
Solve the My Calendar III problem on ExecCode. Free online hard DSA practice in Design. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Implement a calendar where book(start, end) adds a new event covering [start, end) and returns the maximum number of events that overlap at any single point in time so far, considering every event ever booked (a "k-booking").
Examples
Input operations = ["MyCalendarThree", "book", "book", "book", "book", "book", "book"], values = [[], [10, 20], [50, 60], [10, 40], [5, 15], [5, 10], [25, 55]]; Output [null, 1, 1, 2, 3, 3, 3]. Input operations = ["MyCalendarThree", "book", "book"], values = [[], [1, 4], [4, 7]]; Output [null, 1, 1]. Input operations = ["MyCalendarThree", "book", "book", "book"], values = [[], [0, 10], [0, 10], [0, 10]]; Output [null, 1, 2, 3]
Constraints
0 ≤ start < end ≤ 10⁹ at most 400 calls will be made to book
Practice My Calendar III free on ExecCode. Browse DSA problems, topic map, and placement guides.