其他分享
首页 > 其他分享> > 链表 160.找出两个链表的交点

链表 160.找出两个链表的交点

作者:互联网

160. Intersection of Two Linked Lists (Easy)---python

class Solution(object):
    def getIntersectionNode(self, headA, headB):
        """
        :type head1, head1: ListNode
        :rtype: ListNode
        """
        if not headA or not headB:
           return Null

        else:
            pa, pb = headA, headB
            while pa is not pb:
                pa = headB if pa == None else pa.next # if  else 为三目表达式
                pb = headA if pb == None else pb.next
            return pa

标签:pb,相遇,else,链表,pa,headB,headA,交点,160
来源: https://www.cnblogs.com/zzychage/p/14993817.html