mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-10 04:06:51 +08:00
Update 面试题02.07链表相交,添加C#版
This commit is contained in:
@ -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;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
Reference in New Issue
Block a user