My Calendar I
Learn this problemProblem statement
You are implementing a calendar that stores booked half-open intervals [start, end).
You are given two integer arrays starts and ends of the same length. The i-th booking attempt requests the interval [starts[i], ends[i]). Accept the booking if and only if it does not overlap any already accepted interval. Adjacent bookings that only touch at an endpoint do not overlap because the end time is exclusive.
Return a boolean array where entry i is true when the i-th attempt is accepted.
Function
bookCalendar(starts: int[], ends: int[]) → boolean[]Examples
Example 1
starts = [10,15,20]ends = [20,25,30]return = [true,false,true]The first booking [10, 20) is accepted. The second booking [15, 25) overlaps it and is rejected. The third booking [20, 30) only touches the accepted interval at time 20, so it is accepted.
Example 2
starts = [47,33,36,25,24]ends = [50,41,45,32,33]return = [true,true,false,true,false][47, 50), [33, 41), and [25, 32) are disjoint and accepted. [36, 45) overlaps [33, 41), and [24, 33) overlaps [25, 32).
Constraints
1 <= starts.length <= 1000.ends.length == starts.length.0 <= starts[i] < ends[i] <= 10^9.