Airbnb software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question You are skiing down from the top of a mountain and want to maximize your score when you reach the finish. There are multiple routes you...
Input: Graph (nodes and edges)n, the sequence is defined as follows: - If n is...Input: Integer(s)Question AirBnB has a need to support refunds for our customers in case of booking changes or cancellations.
Input: Listid, neighborhood, host_id, capacity, and nightly_price. All keys and values are strings; prices are dollar amounts with exactly two decimal places.neighborhood exactly equals the requested neighborhood are eligible. All input properties are already available for the requested dates, and each may be selected at most once.group_size. Minimize total capacity first, then the number of selected properties, then the lexicographically smallest sorted list of property IDs.optimize_properties(properties: list[dict[str, str]], neighborhood: str, group_size: int). The return type is up to the candidate; Example 1 uses a JSON array of IDs as its reference representation.{
"properties": [
{"id": "A", "neighborhood": "Mission", "host_id": "h1", "capacity": "4", "nightly_price": "70.00"},
{"id": "B", "neighborhood": "Mission", "host_id": "h2", "capacity": "3", "nightly_price": "50.00"},
{"id": "C", "neighborhood": "Mission", "host_id": "h3", "capacity": "7", "nightly_price": "150.00"},
{"id": "D", "neighborhood": "Sunset", "host_id": "h4", "capacity": "7", "nightly_price": "120.00"},
{"id": "E", "neighborhood": "Mission", "host_id": "h5", "capacity": "8", "nightly_price": "100.00"}
],
"neighborhood": "Mission",
"group_size": 7
}["C"]
A + B and C both provide exactly 7 places, but C uses one property instead of two. E provides 8 places, and D is ineligible because its neighborhood differs. Price is not an objective.Part 2 — Add traveler-supplied booking policiesoptimize_with_policies(properties: list[dict[str, str]], neighborhood: str, group_size: int, policies: list[dict[str, str]]). The return type remains your choice; the examples use a summary object.{"type": "nightly_budget", "limit": "120.00"}: the sum of selected nightly prices must be less than or equal to the limit. Use exact cents, not floating-point arithmetic.{"type": "host_limit", "limit": "1"}: select at most the specified number of properties from each host. This is a per-host limit, not a limit on the number of distinct hosts.ValueError.status: "OK", sorted property_ids, integer total_capacity, and total_nightly_price formatted with two decimal places. An impossible result contains status: "IMPOSSIBLE", an empty ID list, capacity 0, and price "0.00".{
"properties": [
{"id": "A", "neighborhood": "Mission", "host_id": "h1", "capacity": "4", "nightly_price": "70.00"},
{"id": "B", "neighborhood": "Mission", "host_id": "h2", "capacity": "3", "nightly_price": "50.00"},
{"id": "C", "neighborhood": "Mission", "host_id": "h3", "capacity": "7", "nightly_price": "150.00"},
{"id": "D", "neighborhood": "Sunset", "host_id": "h4", "capacity": "7", "nightly_price": "120.00"},
{"id": "E", "neighborhood": "Mission", "host_id": "h5", "capacity": "8", "nightly_price": "100.00"}
],
"neighborhood": "Mission",
"group_size": 7,
"policies": [
{"type": "nightly_budget", "limit": "120.00"},
{"type": "host_limit", "limit": "1"}
]
}{
"status": "OK",
"property_ids": ["A", "B"],
"total_capacity": 7,
"total_nightly_price": "120.00"
}A + B provides 4 + 3 = 7 places for 70.00 + 50.00 = 120.00, exactly the budget. Each selected host contributes one property, satisfying the host limit. C exceeds the budget by 30.00. E costs less but provides 8 places, so it loses on the primary objective.Example 3:{
"properties": [
{"id": "P", "neighborhood": "Mission", "host_id": "h1", "capacity": "4", "nightly_price": "60.00"},
{"id": "Q", "neighborhood": "Mission", "host_id": "h1", "capacity": "3", "nightly_price": "40.00"},
{"id": "R", "neighborhood": "Mission", "host_id": "h2", "capacity": "7", "nightly_price": "130.00"},
{"id": "S", "neighborhood": "Mission", "host_id": "h3", "capacity": "8", "nightly_price": "101.00"}
],
"neighborhood": "Mission",
"group_size": 7,
"policies": [
{"type": "nightly_budget", "limit": "100.00"},
{"type": "host_limit", "limit": "1"}
]
}{
"status": "IMPOSSIBLE",
"property_ids": [],
"total_capacity": 0,
"total_nightly_price": "0.00"
}P + Q provides 4 + 3 = 7 places for exactly 100.00, but selects two properties from h1, exceeding the limit of 1. R and S individually exceed the budget by 30.00 and 1.00. Adding either to another selection cannot reduce its cost. The selection P + Q + R breaks both policies: its price is 230.00 and its h1 count is 2. The only remaining feasible nonempty selections are P and Q, neither of which accommodates 7 guests.Notes:group_size is from 1 to 440. Exact optimization is required; explain why greedy selection is insufficient."0.00" to "10000.00"; a host limit is an integer string from "0" to "22". Except for unknown policy types, inputs satisfy the stated schema.id, a string neighborhood, and a positive integer capacity. All properties are available for the requested dates, and each property can be selected at most once.Select a subset of properties in target_neighborhood whose combined capacity is at least group_size. Optimize the selection in this order:1. Minimize total capacity while accommodating the entire group.group_size is zero. Neighborhood matching is case-sensitive, and travelers may be divided among selected properties without any additional restrictions.Function or class signatureoptimize_booking(properties: list[Property], target_neighborhood: str, group_size: int) -> list[int]Property has fields id: int, neighborhood: str, and capacity: int.{
"properties": [
{"id": 101, "neighborhood": "SoMa", "capacity": 6},
{"id": 102, "neighborhood": "SoMa", "capacity": 4},
{"id": 103, "neighborhood": "SoMa", "capacity": 10},
{"id": 104, "neighborhood": "SoMa", "capacity": 5},
{"id": 105, "neighborhood": "Mission", "capacity": 10}
],
"target_neighborhood": "SoMa",
"group_size": 10
}Output:[103]Explanation: Both
[101, 102] and [103] provide exactly 10 spaces. Property 103 wins because it uses one property instead of two. Property 105 is in the wrong neighborhood.Example 2:Input:{
"properties": [
{"id": 201, "neighborhood": "Mission", "capacity": 6},
{"id": 202, "neighborhood": "Mission", "capacity": 5},
{"id": 203, "neighborhood": "Mission", "capacity": 4},
{"id": 204, "neighborhood": "SoMa", "capacity": 8}
],
"target_neighborhood": "Mission",
"group_size": 8
}Output:[202, 203]Explanation: No eligible selection has total capacity 8. Properties 202 and 203 provide 9 spaces, which is better than the other feasible totals of 10, 11, and 15.Constraints:
0 <= len(properties) <= 2000.target_neighborhood.[1, 10^9].1 <= capacity <= 10^9.0 <= group_size <= 10^12.target_neighborhood are strings of length 1 through 100.rental_id with their corresponding availability ranges in the form of pairs (start_date, end_date) and a queried date range, return a list of rental IDs that are available during the entire period of the query.def search_available_rentals(rentals: List[Tuple[int, Tuple[int, int]]], query: Tuple[int, int]) -> List[int]: - Returns rental IDs that are available for the entire query date range.1 <= rentals.length <= 10^41 <= rental_id <= 10^61 <= start_date < end_date <= 10^61 <= query[0] < query[1] <= 10^6property_id and a list of neighbors (i.e., directly connected properties).def find_neighbors(properties: List[Property], id: int, distance: int) -> List[int]: - Returns the list of property identifiers of neighboring properties within the specified distance.1 <= properties.length <= 10001 <= property_id <= 10^60 <= distance <= 50Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free