Swap Nodes In Pairs | Recursive and Iterative

Опубликовано: 17 Октябрь 2024
на канале: Fit Coder
2,124
49

In this video, I have explained how to swap nodes pairswise in a linked list.
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)

Source code: https://github.com/fit-coder/fitcoder...

00:00 Introduction
00:08 Problem explanation
01:39 Recursive method
06:39 Iterative method
11:30 Implementation

-------------------------------------------------------------
I live in New Delhi and love explaining programming concepts. I have done M.Tech(BITS Pilani) + B.Tech(PEC, Chandigarh) in Computer Science and am currently working as a software engineer in a MNC.
If you like my content, please like, share my videos and subscribe to the channel.
-------------------------------------------------------------

For Linked List tutorials, please refer to the below playlist:
   • Linked List  

For Binary tree tutorials, please refer to the below playlist:
   • Tree Data Structures  

For Binary search tree tutorials, please refer to the below playlist:
   • Binary Search Tree  

For in-depth Graph theory and implementation details, please refer to the below playlist:
   • Graph Algorithms  

#DataStructure,#LinkedList,#FitCoder,#Algorithm,#competitiveprogramming,#faang,#codinginterview