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 You are in a maze that is represented as a grid of cells, where each cell is either empty (O) or blocked (X). You can move up, down,...
Question AirBnB has a need to support refunds for our customers in case of booking changes or cancellations.
Input: Listbookings, where each booking is represented as a tuple (property_id, user_id), write a function that returns the property_id of the property that has the most bookings. If there are ties, return the property with the smallest property_id.def most_booked_property(bookings: List[Tuple[int, int]]) -> int:[(1, 101), (2, 102), (1, 103), (3, 104), (2, 105), (1, 106)] 1 1 is booked by users 101, 103, and 106 (3 bookings), while properties 2 and 3 are booked 2 and 1 times respectively.[(1, 101), (2, 102), (3, 103), (2, 104), (1, 105), (3, 106), (1, 107)] 1 1 is booked 3 times, while properties 2 and 3 are tied with 2 bookings each but we choose 1 because it has the most.1 <= len(bookings) <= 10^61 <= property_id, user_id <= 10^9listings with associated views, bookings, and ratings, determine how many listings are considered underperforming. A listing is classified as underperforming if it has fewer than min_views AND fewer than min_bookings AND a rating lower than min_rating.def count_underperforming_listings(listings: List[Tuple[int, int, float]], min_views: int, min_bookings: int, min_rating: float) -> intlistings = [(100, 5, 4.5), (50, 3, 4.0), (20, 0, 3.5)], min_views = 30, min_bookings = 2, min_rating = 4.0 2 listings = [(200, 15, 4.8), (150, 10, 3.0), (40, 1, 2.5)], min_views = 50, min_bookings = 5, min_rating = 3.5 1 listings array can contain between 1 and 10^4 entries. views and bookings are non-negative integers. listing_id, return a hash map (dictionary) that counts the number of reviews for each listing. Each review is structured as "listing_id: review content". The output should be a dictionary where the keys are listing_id and the values are the counts of reviews for that listing.def count_reviews(reviews: List[str]) -> Dict[str, int]:reviews = ["1: Great stay!", "1: Loved it!", "2: Not bad.", "1: Would come again."]{'1': 3, '2': 1}reviews = ["3: Awesome experience!", "3: Best place ever!", "2: Clean and nice."]{'3': 2, '2': 1}10^5.listing_id followed by text (up to 200 characters).List[int] identify_underperforming_listings(listings: List[Tuple[int, int, int]]) -> List[int]listings = [(1, 5, 100), (2, 4, 50), (3, 3, 75)] [2, 3] listings = [(1, 4, 200), (2, 3, 200), (3, 5, 300)] [] listings, 1 ≤ number of listings ≤ 1000 listings where each listing is a dictionary containing id, views, and bookings, implement a function to find listings that are considered *underperforming*. A listing is *underperforming* if its ratio of bookings to views is below a given threshold (e.g., 0.1). Return the IDs of the underperforming listings in ascending order.def find_underperforming_listings(listings: List[Dict[str, int]], threshold: float) -> List[int]:find_underperforming_listings([{ 'id': 1, 'views': 100, 'bookings': 5 }, { 'id': 2, 'views': 200, 'bookings': 1 }, { 'id': 3, 'views': 50, 'bookings': 8 }], 0.1) [2] 0.005 which is below the threshold 0.1. find_underperforming_listings([{ 'id': 1, 'views': 300, 'bookings': 30 }, { 'id': 2, 'views': 150, 'bookings': 20 }], 0.1) [] 1 <= len(listings) <= 10^40 <= views, bookings <= 100000 < threshold <= 1def detect_underperforming_listings(listings: List[Dict[str, Union[int, float]]]) -> List[int]:listings = [{'id': 1, 'rating': 3.5, 'bookings': 8}, {'id': 2, 'rating': 4.5, 'bookings': 15}, {'id': 3, 'rating': 3.9, 'bookings': 5}][1, 3] listings = [{'id': 4, 'rating': 4.2, 'bookings': 12}, {'id': 5, 'rating': 3.9, 'bookings': 10}, {'id': 6, 'rating': 3.8, 'bookings': 9}][5, 6] evaluate_underperforming_listings that takes a list of listings in the form of a dictionary and evaluates them against predefined performance metrics. A listing is considered underperforming if it has a rating below 4.0 or has fewer than 5 bookings. The function should return a list of listing IDs that are underperforming.def evaluate_underperforming_listings(listings: List[Dict[str, Union[int, float]]]) -> List[int]:[
{"id": 1, "rating": 4.5, "bookings": 10},
{"id": 2, "rating": 3.8, "bookings": 2},
{"id": 3, "rating": 4.0, "bookings": 0}
] [2, 3]
[
{"id": 1, "rating": 4.2, "bookings": 12},
{"id": 2, "rating": 4.4, "bookings": 5},
{"id": 3, "rating": 3.9, "bookings": 4}
] [3]
1 <= len(listings) <= 1000id with a rating as a float and bookings as an integer.0 <= bookings <= 1000.0 <= rating <= 5.0rental_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 <= 50capacity. The cache should support get(key) and put(key, value) operations.class LRUCache:def __init__(self, capacity: int): - Initializes the LRUCache with the maximum capacity.def get(self, key: int) -> int: - Returns the value of the key if the key exists in the cache, otherwise return -1.def put(self, key: int, value: int): - Update the value of the key if it exists, otherwise add the key-value pair to the cache. When the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.1 <= capacity <= 30000 <= key <= 10^40 <= value <= 10^4Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free