class Solution {
public:
ListNode* getIntersectionNode(ListNode* headA, ListNode* headB) {
ListNode* pa = headA;
ListNode* pb = headB;
while (pa != pb)
{
pa = pa == NULL ? headB : pa->next;
pb = pb == NULL ? headA : pb->next;
}
return pa;
}
};
LeetCode面试题 02.07. 链表相交
最新推荐文章于 2022-02-06 12:51:52 发布