Attached is my code. Does any one know why I get this error? "ERROR: linked structure was modified"
Thanks for your time.
def getIntersectionNode(self, headA, headB): if headA == None or headB == None: return None hA = headA while hA.next != None: hA = hA.next hA.next = headB slow = headA fast = headA while fast != None and fast.next != None: slow = slow.next fast = fast.next.next if slow == fast: p1 = headA p2 = slow while p1 != p2: p1 = p1.next p2 = p2.next return p1 return None
Take care of the note #2 :
The linked lists must retain their original structure after the