Skip to content

Commit 094ff4e

Browse files
committed
160.IntersectionOfTwoLinkedLists
1 parent cdab42e commit 094ff4e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace LeetCodeNote;
2+
3+
public static partial class Solution
4+
{
5+
public static ListNode GetIntersectionNode(ListNode headA, ListNode headB)
6+
{
7+
ListNode? pA = headA;
8+
ListNode? pB = headB;
9+
while (pA != pB)
10+
{
11+
pA = pA is null ? headB : pA.next;
12+
pB = pB is null ? headA : pB.next;
13+
}
14+
return pA;
15+
}
16+
}

0 commit comments

Comments
 (0)