1. Top 6 Recently Asked Uber System Design Questions
Category: Graph system design problemThis collection covers the most frequently asked system design questions at Uber interviews.Input: Graph (nodes and edges) Output: Computed result
system designSeniormessaging#1
1. [OA] Design a Debounced Event Emitter for User Interactions
To improve user experience on the Uber application, managing events such as button clicks or input changes efficiently is critical. A debounced event emitter helps optimize performance by limiting the rate at which events are processed. Problem statement: Implement a debounced event emitter class that ensures that a callback is invoked only after a certain period of inactivity following an event occurrence. Method Signature: - class DebouncedEventEmitter - on(event: string, callback: Function): void — Registers an event with its callback. - emit(event: string): void — Triggers the event and executes callbacks with debounce. - clear(event: string): void — Clears the scheduled callbacks of a certain event.Example 1: Input: on('clicked', () => console.log('Button clicked!')); emit('clicked'); Output: No immediate output; the callback executes after debounce period.Example 2: Input: on('inputChanged', () => console.log('Input changed!')); emit('inputChanged'); (if another input comes after a period) Output: Input changed! (depends on debounce period)Constraints: - 1 <= event.length <= 50` - There can be at most 20 different events.
system designSeniorapi design#2
2. [OA] Design a Client-Side Router for Uber's Application
In a Single Page Application (SPA) like Uber's, a router efficiently manages the view based on URL changes without needing a page reload. Fast transitions between views lead to a smoother user experience. Problem statement: Design a class that handles client-side routing. The router should manage dynamic and static routes, parsing the URL and rendering the appropriate view. Method Signature: - class Router - addRoute(path: string, callback: Function): void — Add a new route. - navigate(path: string): void — Change the current route to the specified path and invoke the corresponding callback. - getCurrentRoute(): string — Returns the current path.Example 1: Input: addRoute('/home', () => console.log('Home Page')) Input: navigate('/home') Output: Home PageExample 2: Input: addRoute('/profile', () => console.log('Profile Page')) Input: navigate('/profile') Output: Profile PageConstraints: - 1 <= path.length <= 100 - There can be at most 10 routes.