Junior Detailed answer Linked Lists DSA & Coding Interviews

How do you reverse a linked list (iterative and recursive)?

Short answer: Iterative: three pointers prev, curr, next. Flip curr.next to prev and advance. Recursive: reverse the rest, then point head.next.next = head and head.next = null. Iterative is usually preferred in interviews for O(1) stack space.

Complexity

Time O(n). Iterative space O(1); recursive space O(n) call stack.

Edge cases to mention

  • Empty list
  • Single node
  • Cycle (clarify — usually assume none)

Common follow-ups

  • Reverse nodes in k-group
  • Reverse between left and right
Draw 3 nodes on the whiteboard before coding — it prevents pointer bugs.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details