Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new empty linked list node with value 0.
DSA Rust
let mut dummy = ListNode::new([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Using None instead of a numeric value.
Using 1 or -1 which are valid but not standard for dummy node.
✗ Incorrect
The dummy node is usually initialized with 0 as a placeholder value.
2fill in blank
mediumComplete the code to move the pointer to the next node in the merged list.
DSA Rust
current = current.[1].as_mut().unwrap();Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' which points backward.
Using 'child' or 'link' which are not standard field names.
✗ Incorrect
In a linked list, the next node is accessed via the 'next' field.
3fill in blank
hardFix the error in the comparison to merge nodes from list1 and list2.
DSA Rust
if list1.as_ref().unwrap().val [1] list2.as_ref().unwrap().val {
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' which picks the larger value first.
Using '==' or '!=' which do not order nodes.
✗ Incorrect
We want to pick the smaller value node first, so use '<' to compare.
4fill in blank
hardFill both blanks to correctly assign the next node and advance the pointer.
DSA Rust
current.[1] = list1.take(); list1 = current.[2].as_mut().unwrap().next.take();
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' or 'child' which are incorrect fields.
Mixing up the order of assignment and pointer movement.
✗ Incorrect
We assign to 'next' and then move list1 to the next node via 'next'.
5fill in blank
hardFill all three blanks to return the merged list skipping the dummy node.
DSA Rust
return dummy.[1].take(); // dummy is a [2] node // .[3] points to the first real node
Attempts:
3 left
💡 Hint
Common Mistakes
Returning dummy instead of dummy.next.
Confusing 'prev' with 'next' pointer.
✗ Incorrect
We return dummy.next because dummy is a ListNode and next points to the merged list start.
