S2
S2 copied to clipboard
LRUCache | LeetCode Cookbook
https://books.halfrost.com/leetcode/ChapterThree/LRUCache/
不错 留个名
想問一下,當整個 list 只有一個 node 時,此時的 head 跟 tail 會指向同一個 node, 但最後模板的 Remove 沒有處理 this.tail 就 return,這樣 this.tail 仍然會指向 node ?
func (this *LRUCache) Remove(node *Node) {
if node == this.head {
this.head = node.Next
node.Next = nil
return
}
...
}
大佬写得很详细,赞
不对吧 Keys map[int]*list.Element 本身就是存的ele 的指针 不存在什么遍历之类的 pair 是什么类型 自定的struct int 都可以
不对吧 Keys map[int]*list.Element 本身就是存的ele 的指针 不存在什么遍历之类的 pair 是什么类型 自定的struct int 都可以
@starsea 你的意思是,不应该遍历 key 么?