Reverse a Singly Linked List In Place

Quick Overview

Reverse a singly linked list by changing links while preserving node identities. Use a reversed-prefix invariant to explain pointer order, termination, edge cases, and constant auxiliary space.

Reverse a Singly Linked List In Place

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Reverse a singly linked list and return its new head. ### Constraints and Clarifications For the standard practice contract, the list is finite and acyclic, each node has a value and a next reference, and an empty list is represented by a null head. Reverse links in place while preserving node values and identities. These structural assumptions make the named reversal task precise; no numerical size or value bounds were reported. ### What a Strong Answer Covers Save the next node before changing a link, maintain a reversed prefix and an unprocessed suffix, and explain the new tail and head. Compare iterative auxiliary space with a recursive approach. ### Follow-up Questions - What goes wrong if current.next is overwritten before saving the old next reference? - How would a cycle in the input affect the termination argument?

Overview: Reverse a singly linked list by changing links while preserving node identities. Use a reversed-prefix invariant to explain pointer order, termination, edge cases, and constant auxiliary space.

Jan 14, 2026
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
0
0

Reverse a singly linked list and return its new head.

Constraints and Clarifications

For the standard practice contract, the list is finite and acyclic, each node has a value and a next reference, and an empty list is represented by a null head. Reverse links in place while preserving node values and identities. These structural assumptions make the named reversal task precise; no numerical size or value bounds were reported.

What a Strong Answer Covers Guidance

Save the next node before changing a link, maintain a reversed prefix and an unprocessed suffix, and explain the new tail and head. Compare iterative auxiliary space with a recursive approach.

Follow-up Questions Guidance

  • What goes wrong if current.next is overwritten before saving the old next reference?
  • How would a cycle in the input affect the termination argument?