腾讯五十题 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;
    }
}
上一篇:docker简要命令


下一篇:Vision Transformer Pruning简记