Split Stay
Asked at Airbnb
Reported by the problem's creator, not verified
A guest wants to stay from day start through day end, both included, but no single listing is free for the whole trip. A split stay books two different listings back to back: the first covers days start through some split day s, the second covers days s + 1 through end. Each listing reports the days it is free, in any order and possibly with repeats.
Examples
Example 1
Input: availability =
[[1,2,3],[3,4,5],[5,4,3,2,1],[2,3,4,5]], start =1, end =5Output:
[[0,1],[0,2],[0,3],[2,1],[2,3]]Explanation: Only listings free on day 1 can come first: 0 and 2. With 0 first, listing 1 covers days 4-5, so [0, 1] works; [0, 2] and [0, 3] also work since both are free on days 2-5. With 2 first, [2, 1] splits after day 2 and [2, 3] splits after day 1. [2, 0] fails because 0 is not free on day 5.