Deviopath › JavaScript

Calendar Without Triple Booking

Hard · Arrays

You are building a calendar that allows double bookings but never triple bookings.

Write a function bookAll that takes a list of booking requests [start, end] and processes them in order. Each booking covers the time from start up to, but not including, end (so [1, 3] and [3, 5] do not overlap).

A request is accepted unless accepting it would make some moment covered by three accepted bookings. Rejected requests are ignored. Return an array of booleans: true for accepted, false for rejected.

Next: Number of Islands