Category: Sliding window system design problemThese are commonly asked system design questions from Rippling interviewsInput: Given input Output: Computed result
system designSeniorapi design#1
1. [OA] Twitter Feed — Design a Social Feed for Rippling's Employee Updates
Rippling wants to implement a social feed where employees can post updates and follow each other, showcasing dynamic interaction and engagement among employees. Problem statement: Design a simple social feed system where each employee can post updates and view a timeline of posts from employees they follow. The feed should support posting updates, and retrieving the latest posts from followed accounts up to a given limit. - Class: SocialFeed - Method: post(employeeId: int, message: str) -> void - allows an employee to post an update. - Method: follow(followerId: int, followeeId: int) -> void - allows a follower to follow an employee. - Method: getFeed(employeeId: int, limit: int) -> List[str] - returns the latest posts from followed employees, limited by the number specified.Example 1: Input: post(1, 'Hello World!') Input: follow(2, 1) Input: getFeed(2, 1) Output: ['Hello World!'] Explanation: Employee 2 follows employee 1 and sees their post.Example 2: Input: post(1, 'Good Morning!') Input: getFeed(2, 2) Output: ['Hello World!', 'Good Morning!'] Explanation: The feed now contains two posts from employee 1.Constraints: - 1 ≤ employeeId ≤ 10^4 - 1 ≤ message.length ≤ 140
system designSeniorcaching#2
2. [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#3
3. [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: - 1 <= capacity <= 3000 - 0 <= key, value <= 10^4