@@ -0,0 +1,2311 @@
+package leetcode;%0A%0Aimport java.util.HashMap;%0Aimport java.util.LinkedList;%0Aimport java.util.Map;%0A%0A/**%0A * https://leetcode.com/problems/lru-cache/%0A */%0Apublic class Problem146 %7B%0A    public static class LRUCache %7B%0A        private final Map%3CInteger, Integer%3E map = new HashMap%3C%3E();%0A        private final LinkedList%3CInteger%3E list = new LinkedList%3C%3E();%0A        private final int capacity;%0A%0A        public LRUCache(int capacity) %7B%0A            this.capacity = capacity;%0A        %7D%0A%0A        public int get(int key) %7B%0A            if (map.containsKey(key)) %7B%0A                list.addLast(key);%0A                list.removeFirst();%0A            %7D%0A            return map.getOrDefault(key, -1);%0A        %7D%0A%0A        public void set(int key, int value) %7B%0A            if (!map.containsKey(key)) %7B%0A                list.addLast(key);%0A            %7D%0A            map.put(key, value);%0A            if (map.size() -1 == capacity) %7B%0A                int removedKey = list.removeFirst();%0A                map.remove(removedKey);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        LRUCache lru = new LRUCache(2);%0A//        lru.set(2, 1);%0A//        lru.set(1, 1);%0A//        System.out.println(lru.get(2)); // 1%0A//        lru.set(4, 1);%0A//        System.out.println(lru.get(1)); // -1%0A//        System.out.println(lru.get(2)); // 1%0A//        lru.set(5, 1);%0A//        lru.set(6, 1);%0A//        System.out.println(lru.get(1)); // -1%0A//        System.out.println(lru.get(2)); // -1%0A//        System.out.println(lru.get(3)); // -1%0A//        System.out.println(lru.get(4)); // -1%0A//        System.out.println(lru.get(5)); // 1%0A//        System.out.println(lru.get(6)); // 1%0A%0A        lru.set(2, 1);%0A        System.out.println(%221. %22 + lru.map);%0A        System.out.println(%221. %22 + lru.list);%0A        lru.set(1, 1);%0A        System.out.println(%222. %22 + lru.map);%0A        System.out.println(%222. %22 + lru.list);%0A        lru.set(2, 3);%0A        System.out.println(%223. %22 + lru.map);%0A        System.out.println(%223. %22 + lru.list);%0A        lru.set(4, 1);%0A        System.out.println(%224. %22 + lru.map);%0A        System.out.println(%224. %22 + lru.list);%0A        System.out.println(lru.get(1)); // -1%0A        System.out.println(lru.get(2)); // 3%0A        System.out.println(%225. %22 + lru.map);%0A        System.out.println(%225. %22 + lru.list);%0A    %7D%0A%7D%0A

Create a skeleton for problem 146