From 451c045a6e293bd038815400de660d3d6d091873 Mon Sep 17 00:00:00 2001 From: eeee0717 <70054568+eeee0717@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:17:40 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E9=9D=A2=E8=AF=95=E9=A2=9802.07?= =?UTF-8?q?=E9=93=BE=E8=A1=A8=E7=9B=B8=E4=BA=A4=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?C#=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/面试题02.07.链表相交.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/problems/面试题02.07.链表相交.md b/problems/面试题02.07.链表相交.md index 5de9da5c..adeaa413 100644 --- a/problems/面试题02.07.链表相交.md +++ b/problems/面试题02.07.链表相交.md @@ -502,6 +502,20 @@ object Solution { } } ``` +### C# +```C# +public ListNode GetIntersectionNode(ListNode headA, ListNode headB) +{ + if (headA == null || headB == null) return null; + ListNode cur1 = headA, cur2 = headB; + while (cur1 != cur2) + { + cur1 = cur1 == null ? headB : cur1.next; + cur2 = cur2 == null ? headA : cur2.next; + } + return cur1; +} +```