← Back to experiences
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/experiences/…$
Level: Mid-Level
Round: Phone Screen · Type: Coding · Difficulty: 6/10 · Duration: 60 min · Interviewer: Neutral
Topics: Cache, TreeMap, Data Structures, Algorithms
Location: Los Gatos, CA
Interview date: 2025-02-15
I implemented a weighted cache with get and put operations. The cache has a total weight limit. When the limit is reached, the key-value pair with the largest weight is removed.
The coding question I received was:
Implement a weighted cache with the following requirements:
get and put operations.My approach:
I used a TreeMap to ensure both get and put operations have a time complexity of O(logN).
Key Insight: The interviewer appreciated my solution, noting that many candidates use a heap, which results in O(N) complexity.