Katkat

Implement weighted-eviction cache

NetflixSoftware Engineer · Technical Screen

Last updated

This question evaluates understanding and practical implementation of data structures and algorithms for a weighted cache, including weighted eviction policies, use of ordered maps, and time-space complexity analysis.

Question

Design and implement a weighted cache supporting get(key) and put(key, value, weight) operations. The cache has a total weight limit; when inserting a new item would exceed the limit, evict the key-value pair with the largest weight. Aim for O(log N) get/put using an ordered map (e.g., TreeMap). Explain your data structures and complexity.