Category: Sliding window system design problemThese are commonly asked system design questions from Rippling interviewsInput: Given input Output: Computed result
system designHardapi design#1
1. Design HotelBookingSystem — manage hotel bookings effectively
Background: Rippling aims to streamline the booking process for various hotels by managing inventory and facilitating reservations across different agents. Building a robust HotelBookingSystem will enhance user experience and operational efficiency. Requirements: 1. Manage multiple hotels and their availability attributes. 2. Allow users to search for hotels based on location, dates, and room types. 3. Facilitate the booking of rooms, ensuring that inventory reflects real-time availability. 4. Handle bookings with customer details and payment confirmation. Class API:
add_hotel(hotel: Hotel) -> None: Adds a new hotel to the system.
search_hotels(location: str, check_in: str, check_out: str, room_type: str) -> List[Hotel]: Returns a list of available hotels based on search criteria.
book_room(hotel_id: str, customer_details: Customer, payment_info: Payment) -> BookingConfirmation: Books a room for a customer and returns a booking confirmation.
cancel_booking(booking_id: str) -> bool: Cancels an existing booking using the booking ID.
Example 1: Input: add_hotel(hotel) Output: None Explanation: Adds the specified hotel object to the hotel booking system.Example 2: Input: search_hotels("New York", "2023-12-01", "2023-12-10", "Deluxe") Output: [Hotel1, Hotel2] Explanation: Returns a list of hotels available in New York for the given stay dates and room type. Constraints:
Maximum of 1000 hotels.
Each hotel can have a maximum of 100 rooms per type.
Search and booking operations should have a response time of under 1 second.
system designMediumapi design#2
2. Graph — Implement a hotel booking system
Background: Rippling needs a robust hotel booking system to manage inventory and bookings efficiently across various properties. This system should provide the ability to handle varying room types, availability, and guest reservations effectively.Problem statement: Create a class HotelBookingSystem that allows users to manage bookings in a hotel. The class should support the following operations: adding hotel rooms, checking availability for a specific date range, and making a reservation if rooms are available. Ensure that the book_room method prevents double bookings and updates the room availability accordingly.Function/class signature:
Explanation: Room 101 is successfully booked for John Doe from October 1 to October 5.
Constraints:
Room IDs are unique integers.
Dates are given in YYYY-MM-DD format.
There can be a maximum of 100 rooms in the system.
Each room can only be booked by one guest for a specific date range.
system designSeniorcaching#3
3. [OA] LRU Cache — Design a Cache for Rippling’s Previous Employee Benefits Access
Rippling needs a robust cache system to manage API requests for retrieving previously accessed employee benefits efficiently. Problem statement: Implement an LRU (Least Recently Used) cache that supports the following operations: get(key: int) -> int (returns the value if the key exists, otherwise -1) and put(key: int, value: int) -> void (updates or adds the key/value pair). When the cache reaches its capacity, it should invalidate the least recently used item.
Class: LRUCache
- Method: get(key: int) -> int - returns the value or -1 if not found. - Method: put(key: int, value: int) -> void - adds or updates the cache.Example 1: Input: put(1, 1) Input: put(2, 2) Input: get(1) Output: 1 Explanation: Cache has key 1 with value 1.Example 2: Input: put(3, 3) Input: get(2) Output: -1 Explanation: Key 2 was evicted when key 3 was added, as the capacity limitation was reached.Constraints:
1 ≤ capacity ≤ 3000
system designSeniorcaching#4
4. [OA] LRU Cache — Implement Rippling's caching layer for transaction history
Rippling processes a large number of transactions, and we need an efficient way to cache recently accessed transaction data to improve retrieval times. Implement a Least Recently Used (LRU) cache that allows storing a limited number of transactions and supports getting and setting transaction data.
Method signatures:
- def __init__(self, capacity: int) — Initialize the cache with a given capacity. - def get(self, key: int) -> int — Retrieve the value for a given key if it exists, otherwise return -1. - def put(self, key: int, value: int) -> None — Store the value for a key in the cache, evicting the least recently used item if necessary.Example 1: Input: cache = LRUCache(2); cache.put(1, 1); cache.put(2, 2); cache.get(1); Output: 1 Explanation: The cache returns the value for key 1. The cache now contains [1, 2] as recently accessed items.Example 2: Input: cache.put(3, 3); cache.get(2); Output: -1 Explanation: The key 2 was evicted when key 3 was added to the full cache.Constraints: