Skip to content

Commit

Permalink
add LC-160
Browse files Browse the repository at this point in the history
Signed-off-by: Tahsin Tunan <[email protected]>
  • Loading branch information
tahsintunan committed Dec 28, 2022
1 parent ee7a3bc commit 465edb2
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions go/0160-intersection-of-two-linked-lists.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func getIntersectionNode(headA, headB *ListNode) *ListNode {
a, b := headA, headB
for a != b {
if a == nil {
a = headB
} else {
a = a.Next
}
if b == nil {
b = headA
} else {
b = b.Next
}
}
return a
}

0 comments on commit 465edb2

Please sign in to comment.