Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new node with given value.
DSA Go
node := &ListNode{Val: [1], Next: nil}Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of a number.
Leaving the value blank.
✗ Incorrect
We create a new node with value 5 as the node's Val field.
2fill in blank
mediumComplete the code to move the slow pointer one step forward.
DSA Go
slow = slow[1]Attempts:
3 left
💡 Hint
Common Mistakes
Using .Next.Next which moves two steps.
Using .Prev which is for doubly linked lists.
✗ Incorrect
To move one step forward in a linked list, use .Next.
3fill in blank
hardFix the error in the loop condition to avoid nil pointer dereference.
DSA Go
for fast != nil && fast[1] != nil {
Attempts:
3 left
💡 Hint
Common Mistakes
Checking fast.Next.Next directly causing runtime error.
Using .Prev or .Head which are invalid here.
✗ Incorrect
We must check fast.Next is not nil before accessing fast.Next.Next.
4fill in blank
hardFill both blanks to correctly move fast and slow pointers inside the loop.
DSA Go
fast = fast[1] slow = slow[2]
Attempts:
3 left
💡 Hint
Common Mistakes
Moving slow pointer two steps.
Using .Prev or .Head which are incorrect.
✗ Incorrect
Fast moves two steps with .Next.Next, slow moves one step with .Next.
5fill in blank
hardFill the blank to return the middle node's value after the loop.
DSA Go
return slow[1]
Attempts:
3 left
💡 Hint
Common Mistakes
Returning slow.Next or slow.Prev which are nodes, not values.
Returning slow.Head which is invalid.
✗ Incorrect
The middle node's value is accessed by slow.Val.
