Based on my comprehensive research, I can now generate the problem statement. The "Split Stay Combinations" problem most closely aligns with the "Generate split-stay pairs efficiently" problem from PracHub with the tags you specified.
You are building an algorithmic service for Airbnb's split-stay feature. Given a set of listings with their availability windows and a guest's requested date range, identify all valid pairs of listings that can seamlessly cover the entire stay. A split stay occurs when a guest stays in one listing for the first portion of their trip, then transitions to a different listing for the remainder—with exactly one transition point between them.
The challenge lies in efficiently pairing listings without redundant iteration, while handling sparse availability data and optimizing for scalability across large inventory sets.
Input:
listings: List of N listings, where each listing is represented as an object or dictionary containing:
id: Integer identifier for the listing (0-indexed)availability: Sorted list of integer day numbers indicating available dates (e.g., days since epoch)L: Integer representing the inclusive start day of the requested date rangeR: Integer representing the inclusive end day of the requested date range (L < R)Output:
(X, Y) of distinct listing indices, where:
[L, s] for some split point s[s+1, R] for the same split point sL ≤ s < R (the split point must create two non-empty segments)List[Tuple[int, int]] representing all valid listing pairsData Types:
Input:
listings = [ {id: 0, availability: [1, 2, 3, 6, 7, 10, 11]}, {id: 1, availability: [3, 4, 5, 6, 8, 9, 10, 13]}, {id: 2, availability: [7, 8, 9, 10, 11]} ] L = 3 R = 11
Output:
[(1, 2)]
Explanation:
Input:
listings = [ {id: 0, availability: [1, 2, 3, 4, 5]}, {id: 1, availability: [5, 6, 7, 8, 9]}, {id: 2, availability: [1, 2, 3, 4, 5, 6, 7, 8, 9]} ] L = 1 R = 9
Output:
[(0, 1)]
Explanation:
Use a two-pointer/binary search approach combined with greedy split-point selection: For each candidate pair of listings (X, Y), binary search to find all feasible split points s where X continuously covers [L, s] and Y continuously covers [s+1, R]. Optimize by preprocessing each listing's availability into interval segments, then checking segment boundaries rather than individual days. A bitmask or bitset can efficiently track which listings can cover specific segment ranges, enabling fast filtering of candidate pairs before performing detailed interval validation.