Compute Bookable Gaps From a Host's Blocked Date Ranges

Last updated: November 29, 2026

Quick Overview

A host's calendar has blocked night ranges from reservations, manual blocks, and synced external calendars, possibly overlapping and unsorted. Given a horizon and a minimum stay length, return every open gap inside the horizon that is long enough to book.

Airbnb
Coding & Algorithms
Software Engineer
Airbnb
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


A host's calendar has blocked night ranges from reservations, manual blocks, and synced external calendars, possibly overlapping and unsorted. Given a horizon and a minimum stay length, return every open gap inside the horizon that is long enough to book.

Airbnb shows availability by merging blocks from many sources, and short orphan gaps between bookings are a known host pain point. The interviewer uses this to check interval reasoning, half-open range conventions, and clipping to a window.

What the Interviewer Expects
  • Agree on half-open [start, end) night ranges
  • Sort by start and sweep with a cursor instead of building a merged list first
  • Clip blocks that extend past the horizon
  • Filter gaps shorter than the minimum stay
  • Handle the gap after the last block
Key Topics to Cover
intervals
sweep line
sorting
calendar logic
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you report gaps shorter than the minimum separately so hosts can discount them?
  • If blocks are inserted one at a time, how do you keep gaps up to date efficiently?
  • How does the answer change if the minimum stay differs by check-in weekday?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Blocks are integer day indexes as [start, end), meaning nights start..end-1 are taken. The horizon is [H0, H1). Return gaps [a, b) with b - a >= min_nights, in order. Overlapping and touching blocks m...

High-Level Design

Sort blocks by start. Keep cursor, the first night not yet known to be blocked. For each block, clip it to the horizon; if it starts after the cursor, the range [cursor, start) is free. Then advance...


Submit Your Answer
Markdown supported