Category: Graph coding problemYou are helping users find the most cost-effective way to get all the services they want for their rental property. You are given: - A list of...Input: Graph (nodes and edges) Output: Computed result
codingHardVerified Question#2
2. Best Ski Route
Category: Graph coding problem# 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) Output: Computed result
codingMediumVerified Question#3
3. Design A Queue
Category: Array coding problemDesign a queue data structure that mimics memory allocation patterns. The queue must store elements in fixed-size blocks (arrays), where each...Input: Array Output: Computed result
codingHardVerified Question#4
4. Menu Order Equaling Target Sum
Category: Algorithm coding problemYou are given a menu containing prices of individual items. Given a target amount of money, find all possible combinations of menu items that...Input: Integer(s) Output: Integer
codingHardVerified Question#5
5. Most Cost Effective Menu Order
Category: Dynamic programming coding problemYou are building an app that helps users determine the most cost-effective order they can place at a restaurant for the food items they want. You...Input: List Output: Computed result
codingMediumVerified Question#6
6. Best Way To Split Stay
Category: Graph coding problemYou are building a property recommendation system for vacation rentals. Given a list of available properties, you need to find the optimal...Input: Graph (nodes and edges) Output: Integer
codingMediumVerified Question#7
7. Maximize Task Points
Category: Algorithm coding problemYou are given a set of tasks, each with a deadline and a reward (profit) for completing it. Each task takes exactly one day to complete, and only...Input: Given input Output: Computed result
codingHardVerified Question#8
8. Collatz Sequence
Category: Algorithm coding problemThe Collatz conjecture is a famous unsolved problem in mathematics. For any positive integer n, the sequence is defined as follows: - If n is...Input: Integer(s) Output: Computed result
codingMediumVerified Question#9
9. Shortest Maze Path
Category: Grid/matrix coding problem# 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,...Input: 2D grid Output:** Integer
codingHardVerified Question#10
10. Implement Refunds
Category: Algorithm coding problem# Question AirBnB has a need to support refunds for our customers in case of booking changes or cancellations.Input: List Output: Array
system designSeniormessaging#1
1. [OA] Message Queue — Design a message queue system for booking notifications
Airbnb requires an effective notification system for its bookings. You need to create a MessageQueue class that handles messages related to bookings, ensuring that they are processed in the order they were received. Define a class MessageQueue with the following methods: - void enqueue(BookingMessage message) - adds a new message to the queue. - BookingMessage dequeue() - removes and returns the next message from the queue; returns null if the queue is empty. - bool isEmpty() - checks if the queue is empty.Example 1: Input: enqueue(new BookingMessage('booking1')) Output: null Input: dequeue() Output: booking1 Input: isEmpty() Output: falseConstraints: - The queue can hold up to 10000 messages.
system designSeniorcaching#2
2. [OA] Caching — Implement a simple distributed cache layer for property listings
Airbnb relies on quick access to property information across various services. You need to design a Cache class that will manage property data in a manner that it can support common operations while ensuring high performance. Define a class Cache with the following methods: - void put(String key, String value) - stores a value in the cache with the given key. - String get(String key) - retrieves the value associated with a key, returning null if the key does not exist. - void invalidate(String key) - removes the value for the key, if it exists.Example 1: Input: put('listing1', 'property A') Output: null Input: get('listing1') Output: property A Input: invalidate('listing1') Output: null Input: get('listing1') Output: nullConstraints: - The cache can contain up to 10000 entries.
codingHardtwo pointers#3
3. [OA] Sliding Window — Implement a booking optimization for overlapping stays
Airbnb must effectively manage bookings to reduce the chance of double bookings on properties. We need to identify gaps or overlaps in bookings to optimize resource allocation. Given a list of bookings with start and end dates, implement a function to find all overlapping bookings. If bookings overlap, record the conflicts. - List<List<Booking>> findOverlappingBookings(List<Booking> bookings) - returns a list of lists, where each sub-list contains bookings that overlap.Example 1: Input: bookings = [(1, 5), (3, 7), (6, 10), (8, 12)] Output: [[1, 5], [3, 7], [6, 10], [8, 12]] Explanation: Bookings (1,5) and (3,7) overlap; (6,10) and (8,12) overlap too.Example 2: Input: bookings = [(1, 2), (2, 3), (4, 5)] Output: [] Explanation: There are no overlapping bookings.Constraints: - 1 <= number of bookings <= 10^4 - Start and end dates are unique integers.
codingHardgraph#4
4. [OA] Graph Traversal — Design a service to find available listings based on proximity and neighborhood preferences
Airbnb needs a reliable way to suggest listings based on users' current location and preferred neighborhoods. This can enhance user experience by showing them properties that are not only available but also suitable to their tastes. Given a graph where nodes represent properties and edges represent distances between them, implement a function to find properties that are within a certain distance from a given location. The graph can have varying distances between nodes to reflect real geographical positioning. - List<Property> findAvailableProperties(String location, int maxDistance) - returns a list of properties available within the specified distance from the given location.Example 1: Input: location = 'Central Park', maxDistance = 2 Output: ['Listing A', 'Listing B', 'Listing C'] Explanation: Properties A, B, and C are within 2 kilometers of Central Park.Example 2: Input: location = 'Brooklyn Bridge', maxDistance = 1 Output: ['Listing D'] Explanation: Only Listing D is available within 1 kilometer of Brooklyn Bridge.Constraints: - 1 <= number of properties <= 10^5 - 1 <= maxDistance <= 100 - Property names are unique strings.