Merge In Between Linked Lists | Easy Straight Forward | AMAZON | Leetcode 1669 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 20th Video of our Playlist "LinkedList : Popular Interview Problems".
In this video we will try to solve a good linkedlist practice problem : Merge In Between Linked Lists | Leetcode 1669 | codestorywithMIK
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Merge In Between Linked Lists | Leetcode 1669 | codestorywithMIK
Company Tags : Amazon
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Linked%20List/Merge%20In%20Between%20Linked%20Lists.cpp
GfG Problem Link : https://leetcode.com/problems/merge-in-between-linked-lists/description/
My DP Concepts Playlist : https://youtu.be/7eLMOE1jnls
My Graph Concepts Playlist : https://youtu.be/5JGiZnr6B5w
My Recursion Concepts Playlist : https://www.youtube.com/watch?v=pfb1Zduesi8&list=PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Interview_DS_Algo
Instagram : https://www.instagram.com/codestorywithmik/
Facebook : https://www.facebook.com/people/codestorywithmik/100090524295846/
Twitter : https://twitter.com/CSwithMIK
Subscribe to my channel : https://www.youtube.com/@codestorywithMIK
Approach Summary :
The provided C++ code presents a solution for merging a second linked list (`list2`) into the first linked list (`list1`) by removing a segment of nodes from `list1` between indices `a` and `b` (inclusive) and inserting `list2` in their place.
In the approach:
Initially, two pointers are initialized: `left` (set to NULL) and `right` (set to the head of `list1`).
A loop traverses `list1` until reaching the node at index `b`, updating the `left` pointer when the node at index `a - 1` is reached.
The `left` pointer is linked to the head of `list2`, effectively inserting `list2` into `list1`.
Another loop traverses `list2` to find its last node.
The last node of `list2` is connected to the node following the removed segment in `list1`.
Finally, the modified `list1` is returned.
This approach efficiently merges `list2` into `list1` while maintaining the original order of nodes in both lists.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #newyear2024