Implement a recency cache and min-coins DP
Company: Verkada
Role: Frontend Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
The algorithm round covered two coding problems:
1. Design a fixed-capacity in-memory key-value cache that evicts the least recently accessed item when full. Implement:
- `Cache(int capacity)`
- `int get(int key)` which returns `-1` if the key does not exist
- `void put(int key, int value)`
Both operations should run in O(1) average time.
2. Given a list of positive coin denominations and a target amount, return the minimum number of coins needed to form exactly that amount. If the amount cannot be formed, return `-1`. You may use each denomination any number of times.
Quick Answer: This question evaluates data structure design and algorithmic problem-solving skills, focusing on an LRU-style recency cache and a dynamic programming minimum-coin change problem, and tests knowledge of efficient state management and optimization under constraints.