Lesson overview · Free interview practice

Linked List Reversal

Reverse linked lists in-place.

Topics in the full lesson
  • Concept and Use Cases
  • When to Use
  • Time and Space Complexity
  • Reversing the Entire Linked List
  • Reversing a Part of the Linked List
  • Reversing Nodes in k-Sized Groups

Practice Problems

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

Completion marks record your own progress, not an automatically checked result. The task type does not determine whether it is optional.

Question

Given the head of a singly linked list and two integers left and right (with 1 <= left <= right <= length), reverse the nodes from position left to position right (inclusive) and return the modified list. Solve in one pass.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the nodes — only node connections may be changed.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Question

Given the head of a linked list, reverse the nodes k at a time and return the new head. If the number of nodes is not a multiple of k, leave the final group of fewer than k nodes as-is. Only the node links may be changed, not the values.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Linked List Reversal material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium