
In this article, we have explained an efficient approach to Swap adjacent nodes in a Singly Linked List inplace. We have presented both Iterative and Recursive implementation.
Table of contents:
Problem StatementApproachIllustrationIterative SolutionRecursive Solution
This is similar to Leetcode Problem 24. Swap Nodes in Pairs.
Problem Statement
We’re given the pointer to the head of a singly linked list, we're asked to reverse each two adjacent nodes and return the pointer/reference to th...
Published on November 04, 2021 09:48