This commit is contained in:
2026-06-13 04:08:10 +10:00
parent ec07a9322b
commit 3bce899398
5 changed files with 180 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
package top100liked
// https://leetcode.cn/problems/intersection-of-two-linked-lists/?envType=study-plan-v2&envId=top-100-liked
type ListNode struct {
Val int
Next *ListNode
}
func getIntersectionNode(headA, headB *ListNode) *ListNode {
vis := map[*ListNode]bool{}
for tmp := headA; tmp != nil; tmp = tmp.Next {
vis[tmp] = true
}
for tmp := headB; tmp != nil; tmp = tmp.Next {
if vis[tmp] {
return tmp
}
}
return nil
}