Airbnb Interview Experience
Real interview experiences. Read Experiences →
Airbnb coding interview questions with solutions. Practice DSA problems asked in Airbnb SWE interviews 2025.
Practice 25+ Airbnb coding interview questions with solutions. Airbnb focuses on clean code and practical problems.
Find all listings within price range and location radius.
import math
def search_listings(listings, min_price, max_price, user_lat, user_lng, radius_km): def haversine_distance(lat1, lng1, lat2, lng2): R = 6371 # Earth's radius in km dlat = math.radians(lat2 - lat1) dlng = math.radians(lng2 - lng1) a = (math.sin(dlat/2)**2 + math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) * math.sin(dlng/2)**2) return 2 * R * math.asin(math.sqrt(a))
results = [] for listing in listings: if min_price <= listing['price'] <= max_price: distance = haversine_distance( user_lat, user_lng, listing['lat'], listing['lng'] ) if distance <= radius_km: results.append({**listing, 'distance': distance})
return sorted(results, key=lambda x: x['distance'])Find available dates for a listing given bookings.
from datetime import datetime, timedelta
def find_available_dates(bookings, start_date, end_date): """ bookings: [(check_in, check_out), ...] Returns list of available date ranges """ # Sort bookings by check-in bookings = sorted(bookings, key=lambda x: x[0])
available = [] current = start_date
for check_in, check_out in bookings: if current < check_in: available.append((current, check_in - timedelta(days=1))) current = max(current, check_out + timedelta(days=1))
if current <= end_date: available.append((current, end_date))
return availableCheck if a new booking conflicts with existing ones.
def has_conflict(existing_bookings, new_check_in, new_check_out): """ Returns True if there's a conflict """ for check_in, check_out in existing_bookings: # Overlap exists if one booking starts before other ends if new_check_in < check_out and new_check_out > check_in: return True return False
def find_conflicts(bookings): """ Find all conflicting booking pairs """ conflicts = [] n = len(bookings)
# Sort by check-in time sorted_bookings = sorted(enumerate(bookings), key=lambda x: x[1][0])
for i in range(n): for j in range(i + 1, n): idx_i, (in_i, out_i) = sorted_bookings[i] idx_j, (in_j, out_j) = sorted_bookings[j]
if in_j >= out_i: break # No more conflicts possible
conflicts.append((idx_i, idx_j))
return conflictsdef simple_sentiment(review, positive_words, negative_words): """ Simple bag-of-words sentiment """ words = review.lower().split() pos_count = sum(1 for w in words if w in positive_words) neg_count = sum(1 for w in words if w in negative_words)
if pos_count > neg_count: return 'positive' elif neg_count > pos_count: return 'negative' return 'neutral'
def aggregate_reviews(reviews): """ Aggregate review scores """ if not reviews: return {'avg': 0, 'count': 0}
total = sum(r['rating'] for r in reviews) return { 'avg': round(total / len(reviews), 2), 'count': len(reviews), 'breakdown': { 5: sum(1 for r in reviews if r['rating'] == 5), 4: sum(1 for r in reviews if r['rating'] == 4), 3: sum(1 for r in reviews if r['rating'] == 3), 2: sum(1 for r in reviews if r['rating'] == 2), 1: sum(1 for r in reviews if r['rating'] == 1), } }Paginate search results ensuring host diversity per page.
def paginate_with_diversity(listings, page_size): """ Ensure no host appears more than once per page """ pages = [] remaining = listings.copy()
while remaining: page = [] hosts_in_page = set() deferred = []
for listing in remaining: if len(page) >= page_size: deferred.append(listing) elif listing['host_id'] not in hosts_in_page: page.append(listing) hosts_in_page.add(listing['host_id']) else: deferred.append(listing)
# Fill remaining slots from deferred if needed for listing in deferred: if len(page) >= page_size: break page.append(listing)
pages.append(page) remaining = [l for l in deferred if l not in page]
return pagesfrom collections import defaultdict, deque
def alien_order(words): graph = defaultdict(set) in_degree = {c: 0 for word in words for c in word}
for i in range(len(words) - 1): w1, w2 = words[i], words[i + 1] min_len = min(len(w1), len(w2))
if len(w1) > len(w2) and w1[:min_len] == w2[:min_len]: return ""
for j in range(min_len): if w1[j] != w2[j]: if w2[j] not in graph[w1[j]]: graph[w1[j]].add(w2[j]) in_degree[w2[j]] += 1 break
queue = deque([c for c in in_degree if in_degree[c] == 0]) result = []
while queue: c = queue.popleft() result.append(c) for neighbor in graph[c]: in_degree[neighbor] -= 1 if in_degree[neighbor] == 0: queue.append(neighbor)
return ''.join(result) if len(result) == len(in_degree) else ""def pour_water(heights, volume, k): for _ in range(volume): # Try left first left = k while left > 0 and heights[left - 1] <= heights[left]: left -= 1
# If can't go left, try right if heights[left] >= heights[k]: right = k while right < len(heights) - 1 and heights[right + 1] <= heights[right]: right += 1
if heights[right] >= heights[k]: heights[k] += 1 else: heights[right] += 1 else: heights[left] += 1
return heightsimport heapq
def min_meeting_rooms(intervals): if not intervals: return 0
intervals.sort(key=lambda x: x[0]) heap = []
for start, end in intervals: if heap and heap[0] <= start: heapq.heappop(heap) heapq.heappush(heap, end)
return len(heap)from collections import OrderedDict
class LRUCache: def __init__(self, capacity): self.cache = OrderedDict() self.capacity = capacity
def get(self, key): if key not in self.cache: return -1 self.cache.move_to_end(key) return self.cache[key]
def put(self, key, value): if key in self.cache: self.cache.move_to_end(key) self.cache[key] = value if len(self.cache) > self.capacity: self.cache.popitem(last=False)def is_valid(s): stack = [] mapping = {')': '(', '}': '{', ']': '['}
for char in s: if char in mapping: top = stack.pop() if stack else '#' if mapping[char] != top: return False else: stack.append(char)
return not stackAirbnb Interview Experience
Real interview experiences. Read Experiences →
Airbnb Preparation Guide
Complete preparation strategy. View Guide →
Practice booking/search problems for Airbnb!
Last updated: February 2026