Nasuke
Nasuke
```js // Vue3的keepalive组件就用了这个LRU管理组件的缓存 var LRUCache = function (capacity) { this.map = new Map() this.capacity = capacity } LRUCache.prototype.get = function (key) { if (this.map.has(key)) { let value = this.map.get(key) //...
## 并查集的做法 ```js /** * @param {character[][]} grid * @return {number} */ class UnionSet { constructor(n) { this.fa = Array(n + 1) for (let i = 0; i < n;...
是不能用split 和 join那题吗 ```js let url = 'www.baidu.toutiao.com' function reverseURL(str) { const len = str.length let i = j = 0 let res = '' while(j < len){ if(str[j] ===...
```js const arr = [1, [2, 3, [4, 5]], 1, 2, [6, 7]] Array.prototype.falt = function () { return this.reduce((pre, cur) => { cur instanceof Array ? pre.push(...cur.falt()) : pre.push(cur)...