LRU-like method using LinkedHashMap
Java
Hard
5 views
Problem Description
Task: build a helper method that returns a LinkedHashMap with accessOrder enabled.
Output Format
Return value
Constraints
Capacity passed in.
Official Solution
static java.util.LinkedHashMap<Integer,Integer> newAccessMap(int cap){return new java.util.LinkedHashMap<>(16,0.75f,true){protected boolean removeEldestEntry(java.util.Map.Entry<Integer,Integer> e){return size()>cap;}};}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!