Traba
Quick Navigation
Summary
I had a phone screen interview with Traba where I was asked to implement a cache with specific eviction policies and discuss time complexity improvements. I presented my approach and am hopeful for a positive outcome.
Full Experience
Not too bad of an interview problem! The best part was that the interviewer does not expect working code. In fact, for my approach, I was allowed to stub out some of the functions but I talked through the mechanics.
Fingers crossed for a pass
Interview Questions (1)
Q1
Implement Cache with Priority and LRU Eviction Policy
Data Structures & Algorithms
Your job is to implement a cache as per the below requirements:
get(key: string)set(key: string, value: string, priority: int)evictCache
Eviction policy:
- Remove the key/value pair with the highest priority number
- If there is a tie, remove the least recently accessed key/value pair
Followup: Any opportunity to improve the time complexity of evictCache. I had a linear time complexity and needed to discuss how to improve it