This question evaluates reasoning about interval coverage, set membership, combinatorial pairing of resources, and efficient processing of unsorted availability lists, reflecting skills in algorithm design and use of appropriate data structures.
You are implementing a simplified “split stay” feature.
You are given:
n
hotels (or listings), indexed
0..n-1
.
i
, an
unsorted
list
avail[i]
of integer dates (e.g., days since epoch) indicating the dates that hotel is available.
[start_date, end_date]
.
A split stay means the guest stays in two different hotels in two contiguous, non-empty segments that exactly cover the requested range:
s
such that
start_date ≤ s < end_date
.
A
must be available for
every date
in
[start_date, s]
.
B
must be available for
every date
in
[s+1, end_date]
.
s
and
s+1
.
A != B
.
Return all distinct valid combinations as tuples:
(A, B, s)
meaning hotel A covers the left segment [start_date, s] and hotel B covers the right segment [s+1, end_date].
Notes:
avail[i]
contains duplicates, they should not create duplicate output tuples.
If [start_date, end_date] = [10, 13] and a split s=11 is chosen, then hotel A must cover dates {10,11} and hotel B must cover {12,13}.