2
* @param {number} capacity4
var LRUCache = function (capacity) {5
this.capacity = capacity;6
this.cache = new Map();13
LRUCache.prototype.get = function (key) {14
if (!this.cache.has(key)) {18
let val = this.cache.get(key);19
this.cache.delete(key);20
this.cache.set(key, val);26
* @param {number} value29
LRUCache.prototype.put = function (key, value) {30
if (this.cache.has(key)) {31
this.cache.delete(key);33
if (this.cache.size >= this.capacity) {34
let [lastElm] = this.cache.keys();35
this.cache.delete(lastElm);38
this.cache.set(key, value);42
* Your LRUCache object will be instantiated and called as such:43
* var obj = new LRUCache(capacity)44
* var param_1 = obj.get(key)