Ola Interview Question

Implement LRU cache

Interview Answers

Anonymous

Feb 21, 2018

Pseudocode using various data structures like map and linked lists

1

Anonymous

Jun 8, 2018

public class LRUCache extends LinkedHashMap { private static float loadFactor = 0.75f; private static LRUCache cache ; int size; private LRUCache(int size) { super(size, loadFactor, true); this.size = size; } public static LRUCache getInstance(int size) { return new LRUCache(size); } @Override protected boolean removeEldestEntry(Map.Entry eldest) { return size() > size; } }