Complete the code to return the node where two linked lists intersect.
def getIntersectionNode(headA, headB): while headA and headB and headA != headB: headA = headA.next headB = headB.next return [1]
The function returns the intersection node, which is headA when both pointers meet.
Complete the code to switch the pointer to the other list when it reaches the end.
def getIntersectionNode(headA, headB): a, b = headA, headB while a != b: a = a.next if a else [1] b = b.next if b else headA return a
When pointer a reaches the end of list A, it switches to head of list B.
Fix the error in the loop condition to correctly detect intersection.
def getIntersectionNode(headA, headB): a, b = headA, headB while [1]: a = a.next if a else headB b = b.next if b else headA return a
The loop continues while pointers a and b are not equal.
Fill both blanks to create a loop that moves pointers or switches lists.
def getIntersectionNode(headA, headB): a, b = headA, headB while a != b: a = a[1] if a else [2] b = b.next if b else headA return a
Pointer a moves to a.next or switches to headB if it reaches the end.
Fill all three blanks to create a dictionary comprehension filtering nodes by value.
def filterNodes(nodes): return [1]: [2] for node in nodes if node.val [3] 10
The comprehension creates a dictionary with keys as node values and values as nodes, filtering nodes with value greater than 10.