Design a Weighted Cache (Phone Screen)

Implement a weighted cache WeightedCache<K,V>.

APIs

  • get(K key) -> V | null
  • put(K key, V value, int weight) -> void

Constraints

  • The cache has a maximum capacity maxWeight me...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: