摘要:
// 被观察者类 class Subject { constructor(name) { this.name = name this.observers = [] this.state = 'xx' } // 被观察者提供订阅观察者方法 attach(observer){ this.observer 阅读全文
posted @ 2022-02-21 14:36
Samsara315
阅读(153)
评论(0)
推荐(0)
摘要:
// 压缩字符串 'aaaaaabbbbbcccca' => 'a6b5c4a1' function compressStr(strs = 'aaaaaabbbbbccccaa') { let pre = strs[0] let curNum = 1 let res = '' for (let i 阅读全文
posted @ 2022-02-21 14:34
Samsara315
阅读(1015)
评论(0)
推荐(0)
摘要:
// 新数据插入到链表尾部; // 每当缓存命中(即缓存数据被访问),则将数据移到链表尾部 // 当链表满的时候,将链表头部的数据丢弃。 class LRUCache { constructor(capacity) { this.capacity = capacity this.cache = ne 阅读全文
posted @ 2022-02-21 14:33
Samsara315
阅读(230)
评论(0)
推荐(0)

浙公网安备 33010602011771号