Remove Nodes From Linked List | 3 Detailed Approaches | Story | Leetcode 2487 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 23rd Video of our Playlist "Linked List : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a very good Practice problem on Linked List : Remove Nodes From Linked List | 3 Detailed Approaches | Story To Code | Leetcode 2487 | codestorywithMIK
Reverse LinkedList - https://www.youtube.com/watch?v=RreHsOfi14w
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 : Remove Nodes From Linked List | 3 Detailed Approaches | Story To Code | Leetcode 2487 | codestorywithMIK
Company Tags : Will update soon
My solutions on Github(C++ & JAVA) :https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Linked%20List/Remove%20Nodes%20From%20Linked%20List.cpp
Leetcode Link : https://leetcode.com/problems/remove-nodes-from-linked-list/
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
Summary :
Approach-1 (Using stack):
Time Complexity (T.C): O(n)
Space Complexity (S.C): O(n)
This approach utilizes a stack to store the nodes in reverse order based on their values. It then iterates through the stack, constructing a new linked list with nodes having non-decreasing values. It has a moderate space complexity due to the stack usage.
Approach-2 (Using Recursion):
Time Complexity (T.C): O(n)
Space Complexity (S.C): O(n) due to system stack usage
This approach leverages recursion to traverse the linked list in reverse order. It compares each node with its next node and adjusts the pointers accordingly to create the resulting list. The space complexity is determined by the system stack due to recursive calls.
Approach-3 (Using reverse):
Time Complexity (T.C): O(n)
Space Complexity (S.C): O(1)
This approach involves reversing the linked list and then iterating through it to identify and remove nodes with values less than the maximum encountered so far. It modifies the original list in place, resulting in constant space complexity.
Each approach achieves the same goal of removing nodes with values smaller than any preceding node. The choice between them may depend on considerations such as space constraints, desired coding style, or specific requirements of the application.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
1:45 - Thought Process
8:16 - Approach-1
10:42 - Coding Approach-1
14:02 - Approach-2
21:03 - Coding Approach-2
23:03 - Approach-3
28:12 - Coding Approach-3
#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