public class Solution {
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
ListNode A = headA;
ListNode B = headB;
// 当a走完,走b;当b走完 走a;
while (A != B){
A = A == null? headB : A.next;
B = B == null ? headA : B.next;
}
return A;
}
}
Hot100【八十九】:160. 相交链表
最新推荐文章于 2024-08-26 23:12:47 发布