← Airbnb Interview Insights

Airbnb·Machine Learning Engineer·Technical Phone Screen·Senior

Senior
May 2026

Summary

Airbnb ML Engineer interview with a coding problem that looks like a travel puzzle but is really just coin change in disguise. The decimal durations tripped me up more than the algorithm itself.

Questions Asked (1)

Q1

You have a layover of exactly X hours and a list of Airbnb experiences with decimal durations (in hours). You can book the same experience multiple times. Find the minimum number of bookings so the total duration equals exactly X hours. If it's impossible, return -1.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The thematic wrapper fooled me for a second.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as an unbounded knapsack/coin change problem where you need to find the minimum number of items to sum exactly to X. Use dynamic programming with a 1D array of size X+1, initialized to infinity except dp[0]=0, and iterate through all durations to update dp values. Return dp[X] if finite, else -1.

Pro tip: Mention that since durations are decimals, convert them to integers by multiplying by a common factor (e.g., 10 or 100) to avoid floating-point precision issues, then scale X accordingly. Also, discuss time and space complexity and potential optimizations like BFS for minimum coins.

1. Clarify the problem and constraints

Restate the problem to ensure understanding: given a target X and a list of decimal durations, find the minimum number of bookings (with repetition allowed) to sum exactly to X. Ask about constraints (e.g., X up to what value, number of experiences, precision of decimals) to determine the appropriate algorithm.

2. Handle decimal precision

Convert all durations and X to integers by multiplying by a power of 10 (e.g., 100) to avoid floating-point errors. This transforms the problem into an integer coin change problem.

3. Choose the algorithm

Use dynamic programming (bottom-up) for minimum coins: create an array dp of size X+1, initialize dp[0]=0 and others to infinity. For each amount from 1 to X, iterate through durations and update dp[amount] = min(dp[amount], dp[amount - duration] + 1). Alternatively, use BFS for unweighted shortest path.

4. Implement and test

Write code carefully, handling edge cases (X=0, no durations, impossible cases). Test with small examples and consider time/space complexity (O(X * N) time, O(X) space).

5. Discuss trade-offs and optimizations

Mention alternative approaches like BFS (which can be more efficient if X is small) or mathematical insights (e.g., if all durations share a gcd that doesn't divide X, return -1). Discuss how to handle large X or many experiences.

Key Points to Mention

  • Dynamic programming (unbounded knapsack/coin change) for minimum number of items
  • Decimal to integer conversion to avoid floating-point precision issues
  • Time and space complexity analysis (O(X * N) time, O(X) space)
  • Edge cases: X=0, impossible cases (return -1), no durations
  • Alternative approaches: BFS for shortest path, or mathematical gcd check for impossibility
  • Potential optimizations: using BFS when X is small, or pruning durations larger than X

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.