Airbnb software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
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,...
bookings, 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.0Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free