Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new node with the sum digit.
DSA Python
new_node = ListNode([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum // 10 instead of sum % 10
Adding 10 to sum instead of modulo
Multiplying sum by 10
✗ Incorrect
The digit to store in the node is the remainder when sum is divided by 10.
2fill in blank
mediumComplete the code to update the carry after adding two digits.
DSA Python
carry = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using modulo instead of integer division
Adding 1 to sum instead of dividing
Subtracting 10 from sum
✗ Incorrect
Carry is the quotient when sum is divided by 10.
3fill in blank
hardFix the error in the loop condition to continue while nodes or carry exist.
DSA Python
while l1 or l2 or [1]:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum which is undefined here
Using new_node which is a node, not a condition
Using None which stops the loop
✗ Incorrect
The loop must continue if there is a carry left to add.
4fill in blank
hardFill both blanks to correctly move to the next nodes in the lists.
DSA Python
l1 = l1[1] if l1 else None l2 = l2[2] if l2 else None
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using .prev which is for doubly linked lists backwards
Using .head or .tail which are not node pointers
✗ Incorrect
We move to the next node in each linked list using the .next attribute.
5fill in blank
hardFill both blanks to initialize the dummy node, set current pointer, and return the result list.
DSA Python
dummy = ListNode([1]) current = dummy ... return dummy[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning dummy instead of dummy.next
Using None instead of 0 for dummy node value
Using .prev which is not correct here
✗ Incorrect
Dummy node starts with 0, current points to dummy, and we return dummy.next as the head of the result list.