Medium · System Design
My Calendar I
Given a sequence of book(start, end) calls for half-open intervals [start, end), return for each call whether the interval can be added without overlapping any previously accepted booking (touching endpoints is allowed); accepted bookings are kept.
Examples
Example 1
{
"books": [
[10, 20],
[15, 25],
[20, 30]
]
}Output: true, false, true
Example 2
{
"books": [
[10, 20],
[30, 40],
[5, 25],
[12, 15],
[20, 30],
[25, 35]
]
}Output: true, true, false, false, true, false
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.