Round 1 — DSA
There is a car and N riders. Each rider has two constraints:
- L[i] — the minimum number of other riders this rider is willing to share the ride with.
- H[i] — the maximum number of other riders this rider is willing to share the ride with.
If k riders are selected, every selected rider must satisfy L[i] <= k - 1 <= H[i].
The goal is to maximize the number of riders who can ride together (i.e. maximize k).
Example:
N = 5
L = [0, 1, 1, 2, 2]
H = [1, 2, 2, 4, 4]
Output: 3
The required time complexity is O(N).
Round 2 — LLD
Design a basic file system that supports mkdir and ls. The interviewer mostly cared about the design and the approach, and I did not need to write complete runnable code. I had to draw an entity/class diagram and explain the design. The discussion covered:
- File and Directory entities
- Directory hierarchy
- How to represent parent-child relationships
- How mkdir creates a directory
- How ls traverses/lists contents
- Entity/class relationships
Round 3 — System Design
Design a distributed URL shortener. We discussed the overall distributed architecture and how it runs at scale, with these areas to focus on:
- URL shortening API
- Redirect API
- Unique short-code generation
- Database/storage
- Caching
- Distributed ID generation
- Read/write scalability
- Handling very high redirect traffic
- Availability and fault tolerance
- Expiration of URLs
- Collision handling
- Database partitioning/sharding
Discussion
Loading comments…