腾讯五十题 No.35 相交链表
作者:互联网
public class Solution {
public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
if(headA == null || headB == null) return null;
ListNode pa = headA,pb = headB;
while(pa != pb){
pa = pa != null? pa.next : headB;
pb = pb != null? pb.next : headA;
}
return pa;
}
}
标签:No.35,pb,ListNode,链表,pa,headB,headA,腾讯,null 来源: https://www.cnblogs.com/jianjiana/p/15873487.html