← Linked List Quiz: all 8 questions
Linked List Quiz · Question 6 of 8
To remove the N-th node from the end in one pass, you…
To remove the N-th node from the end in one pass, you…
- A.Reverse the list twice
- B.Move a fast pointer N steps ahead, then move both until fast reaches the end
- C.Count the length with recursion
- D.Use binary search
Answer & explanation
Correct answer: Move a fast pointer N steps ahead, then move both until fast reaches the end
The gap of N between the pointers lands the slow pointer just before the node to delete.
Can you get the rest right without peeking?
Take the timed Linked List Quiz quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →