S2 icon indicating copy to clipboard operation
S2 copied to clipboard

LRUCache | LeetCode Cookbook

Open halfrost opened this issue 4 years ago • 5 comments

https://books.halfrost.com/leetcode/ChapterThree/LRUCache/

halfrost avatar Jan 03 '21 16:01 halfrost

不错 留个名

scientiacoder avatar Mar 06 '21 13:03 scientiacoder

想問一下,當整個 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
	}
    ...
}

wagaru avatar Dec 16 '21 09:12 wagaru

大佬写得很详细,赞

Andylixunan avatar Jan 26 '22 20:01 Andylixunan

不对吧 Keys map[int]*list.Element 本身就是存的ele 的指针 不存在什么遍历之类的 pair 是什么类型 自定的struct int 都可以

starsea avatar Aug 19 '22 10:08 starsea

不对吧 Keys map[int]*list.Element 本身就是存的ele 的指针 不存在什么遍历之类的 pair 是什么类型 自定的struct int 都可以

@starsea 你的意思是,不应该遍历 key 么?

halfrost avatar Aug 19 '22 22:08 halfrost