@@ -0,0 +1,2216 @@
+// https://leetcode-cn.com/problems/lru-cache/solution/%0Aclass LRUCache %7B%0A    private int capacity = 0;%0A    private Node head;%0A    private Node last;%0A    private Map%3CInteger, Node%3E map;%0A%0A    public LRUCache(int capacity) %7B%0A        this.capacity = capacity;%0A        this.map = new HashMap%3CInteger, Node%3E(capacity);%0A    %7D%0A    %0A    public int get(int key) %7B%0A        Node node = map.get(key);%0A        if (null != node) %7B%0A            moveNodeFirst(node);%0A            return node.value;%0A        %7D%0A        return -1;%0A    %7D%0A    %0A    public void put(int key, int value) %7B%0A        Node node = map.get(key);%0A        if (null == node) %7B%0A            if (map.size() == capacity) %7B%0A                removeLast();%0A            %7D%0A            node = new Node();%0A            node.key = key;%0A            node.value = value;%0A            map.put(key, node);%0A        %7D else %7B%0A            node.value = value;%0A        %7D      %0A        moveNodeFirst(node);        %0A    %7D%0A%0A    private void removeLast() %7B%0A        if (null == last) %7B%0A            return;%0A        %7D%0A        map.remove(last.key);%0A%0A        if (last != head) %7B%0A            last.pre.next = null;%0A            last = last.pre;%0A        %7D else %7B%0A            last = null;%0A            head = null;%0A        %7D%0A%0A    %7D%0A%0A    private void moveNodeFirst(Node node) %7B%0A        if (null == head) %7B%0A            head = node;%0A            last = node;%0A            return;%0A        %7D%0A%0A        if (node == head) %7B%0A            return;%0A        %7D%0A%0A        if (node == last) %7B%0A            last = node.pre;%0A            last.next = null;%0A            node.pre = null;%0A            node.next = head;%0A            head.pre = node;%0A            head = node;%0A            return;%0A        %7D%0A%0A        // %E9%93%BE%E4%B8%AD%E8%8A%82%E7%82%B9%0A        if (node.pre != null) %7B%0A            node.pre.next = node.next;%0A            node.next.pre = node.pre;%0A        %7D%0A%0A        // %E5%85%A8%E6%96%B0%E8%8A%82%E7%82%B9%0A        node.pre = null;%0A        node.next = head;%0A        head.pre = node;%0A        head = node;      %0A    %7D%0A%0A    class Node %7B%0A        Node pre;%0A        Node next;%0A        int key;%0A        int value;%0A    %7D    %0A%7D%0A%0A/**%0A * Your LRUCache object will be instantiated and called as such:%0A * LRUCache obj = new LRUCache(capacity);%0A * int param_1 = obj.get(key);%0A * obj.put(key,value);%0A */%0A

Create lru.java