Implement Cache and Key-Value Store
Company: Lyft
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
The interview report mentions coding tasks similar to the following:
1. **Bounded cache**
Implement a cache with a fixed capacity. Support:
- `get(key)` returning the stored value or a not-found result
- `put(key, value)` inserting or updating a key
Any successful `get` or `put` should make the key the most recently used item. If inserting a new key would exceed capacity, evict the least recently used key. Target `O(1)` average time for each operation.
2. **In-memory key-value store**
Implement a simple in-memory key-value store supporting:
- `put(key, value)`
- `get(key)`
- `delete(key)`
After completing one working solution, discuss or implement a second valid approach with different trade-offs, and explain the advantages and disadvantages of each design.
Quick Answer: This question evaluates the ability to design efficient in-memory data structures and caching mechanisms, focusing on core key-value operations, eviction behavior, and performance constraints.