Software Engineer • Mid-Level
Software Engineer • Mid-Level
High QualityPractice Other Questions that Netflix Asked
Continue with targeted prep from Netflix's coding question bank and system design questions.
Interview Summary
The coding problem involved implementing a weighted cache that evicts the heaviest items when its total weight exceeds a configured capacity. The system design discussion focused on advertisement frequency capping, while the database design portion involved modeling advertising orders. The behavioral questions covered my previous projects and experience collaborating across teams.
Interview Details
Round 1 — Coding: Design a Weighted Cache
The coding question asked me to implement a cache that stores key-value pairs, where each entry has an associated positive integer weight. Unlike a conventional LRU cache, eviction was determined by item weight rather than recency of access. The cache had a maximum total weight capacity, represented by maxTotalWeight. Whenever an insertion or update caused the combined weight of cached items to exceed this limit, the cache needed to evict entries with the largest weights first.
Part 1 — Implement the WeightedCache Class
The required class supported the following operations:
WeightedCache(int maxTotalWeight): Initialize a cache with the specified maximum total weight.String get(String key): Return the associated value if the key exists, or an empty string if it does not.void put(String key, String value, int weight): Insert a new entry or update an existing entry's value and weight.
Each entry's weight was a positive integer, and the sum of all weights in the cache could never exceed maxTotalWeight.
If an individual entry's weight exceeded the maximum capacity, the put operation had to be ignored. When eviction was necessary, the cache needed to remove the largest-weight entries first, with arbitrary tie-breaking allowed when multiple entries had equal weights.
Constraints
1 <= maxTotalWeight <= 10^9- Every entry has a positive integer weight.
- Keys and values are non-empty printable ASCII strings.
- At most
10^5totalputandgetoperations.
**Example — Weighted Cache
Unlock Full Details
Create a free account to unlock this interview experience report.