通过判断节点是否相等进行第一个公共节点的处理,对于长度不相等的情形,进行节点对换

# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

#
# 
# @param pHead1 ListNode类 
# @param pHead2 ListNode类 
# @return ListNode类
#
class Solution:
    def FindFirstCommonNode(self , pHead1 , pHead2 ):
        # write code here
        a = pHead1
        b = pHead2
        while a!=b:
            a = a.next if a else pHead2
            b = b.next if b else pHead1
        return a