I had my phone screen today with Tesla for SWE position, I was asked to implement PriorityExpirationCache with LRU
1 If an expired item is available. Remove it. If multiple items have the same expiry, removing any one suffices.
2 If condition 1 can’t be satisfied, remove an item with the least priority.
3 If more than one item satisfies condition 2, remove the least recently used one.
4 Multiple items can have the same priority and expiry.
I couldn't able to come up with implementation in 45mins.
6YOE . Applied through Linkedin and recuirter rwached out to me
EDIT: Updated the conditions to be more readable.