Amazon | Phone Screen | LRU Cache

https://leetcode.com/problems/lru-cache/

Suggested LinkedHashMap and/OR Doubly LinkedList Approach
Today I had phone screen with Amazon and he asked to implement LRU Cache. I've implement with LinkedHashMap but he was not convineced with that approach as he was saying everytime when you run get - you remove and append it to head is not efficient as we are calling get methd many times.
I've suggested DLL approach also but he said is the same where you are handling removing and appending to list.

I could not find any better approch for it ? Can someone share how to efficiently implement LRU cache ?

Comments (5)