BackhardLinked List

Invertible Node Chain Reversal Solution

Problem Statement

Given a singly linked list, reverse the sequence of nodes in-place without using any additional storage that scales with input size.

Example 1
Input
[92, 45, 73, 28, 11]
Output
[11, 28, 73, 45, 92]

Explanation: The input list is reversed in-place, resulting in the given output.

Example 2
Input
[5, 17, 22, 9, 13, 8]
Output
[8, 13, 9, 22, 17, 5]

Explanation: The sequence of nodes in the input list is reversed to produce the output.

Example 3
Input
[41, 67, 29, 85, 11, 23]
Output
[23, 11, 85, 29, 67, 41]

Explanation: The input list is transformed by reversing the order of its nodes.

Constraints

  • The input list will have at least one node.
  • The input list will have at most 5000 nodes.
  • Each node's value will be in the range [1, 10^4].
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free