Palindrome Linked List | 4 Approaches | Leetcode 234| codestorywithMIK

Subscribers:
92,300
Published on ● Video Link: https://www.youtube.com/watch?v=Sgi2BHiW0-Q



Duration: 44:53
2,407 views
120


Whatsapp Community Link : https://www.whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
This is the 21st Video of our Playlist "Linked List : Popular Interview Problems".

In this video we will try to solve an easy but very good practice problem asked by Google :
Palindrome Linked List | 4 Approaches | Leetcode 234| 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 : Palindrome Linked List | 4 Approaches | Leetcode 234| codestorywithMIK
Company Tags : GOOGLE
My solutions on Github(C++ & JAVA) : https://github.com/MAZHARMIK/Interview_DS_Algo/blob/master/Linked%20List/Palindrome%20Linked%20List.cpp
Leetcode Link : https://leetcode.com/problems/palindrome-linked-list/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 :
Sure, here's a brief summary of each approach:

1. **Approach-1 (Using extra space)**:
- This approach involves using extra space to store the values of the linked list in an array.
- It iterates through the linked list to populate the array and then compares elements from both ends of the array to check for palindrome.
- Time Complexity: O(n) - where n is the number of elements in the linked list.
- Space Complexity: O(n) - due to the extra space used to store the values.

2. **Approach-2 (Reversing the 2nd half of linked list)**:
- This approach involves reversing the second half of the linked list and then comparing it with the first half.
- It uses two pointers technique (slow and fast) to find the midpoint of the linked list.
- After reversing the second half, it compares each corresponding node of the first and second halves.
- Time Complexity: O(n) - where n is the number of elements in the linked list.
- Space Complexity: O(1) - as it doesn't use extra space proportional to the size of the input.

3. **Approach-3 (Optimized reversing the 2nd half of linked list)**:
- This approach is similar to Approach-2 but optimized for space.
- Instead of using an additional list to reverse the second half, it reverses the second half in-place.
- It also utilizes the two pointers technique to find the midpoint of the linked list.
- After reversing the second half, it compares each corresponding node of the first and second halves.
- Time Complexity: O(n) - where n is the number of elements in the linked list.
- Space Complexity: O(1) - as it doesn't use extra space proportional to the size of the input.

4. **Approach-4 (Using Pure Recursion)**:
- This approach uses pure recursion to check if a linked list is a palindrome.
- It employs a helper function (`solve`) recursively to traverse the linked list.
- The base case checks if the current node is null, returning true if it is.
- During the recursion, it compares the current node with its corresponding node from the end of the list.
- Time Complexity: O(n) - where n is the number of elements in the linked list.
- Space Complexity: O(1) - Auxiliary space, as it doesn't use additional space proportional to the size of the input beyond the call stack.

╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

✨ Timelines✨
00:00 - Introduction
01:00 - Approach-1
2:41 - Approach-2
11:53 - Approach-3
22:10 - Approach-4
34:24 - Coding all of them

#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




Other Videos By codestorywithMIK


2024-03-29Subarrays with K Different Integers | Approach-1 | With Reasons | Leetcode 992 | codestorywithMIK
2024-03-28Count Subarrays Where Max Element Appears at Least K Times | 2 Approaches | Leetcode 2962
2024-03-28Relatable ? 🥹 #codestorywithmik
2024-03-27Length of Longest Subarray With at Most K Frequency | 2 Ways | Leetcode 2958 | codestorywithMIK
2024-03-27Comment down your lines 👨🏻‍💻
2024-03-26Subarray Product Less Than K | Khandani Sliding Window template | Leetcode 713 | codestorywithMIK
2024-03-25First Missing Positive | In Depth Intuition | Clean Code | Leetcode 41 | codestorywithMIK
2024-03-24Longest Common Suffix Queries | Simple TRIE | Clean Code | Leetcode 3093 | codestorywithMIK
2024-03-24Most Frequent IDs | Complete Intuition | Leetcode 3092 | codestorywithMIK
2024-03-22Reorder List | 3 Approaches | Leetcode 143 | codestorywithMIK
2024-03-21Palindrome Linked List | 4 Approaches | Leetcode 234| codestorywithMIK
2024-03-20Task Scheduler | Using Greedy Only | No Heap | Leetcode 621 | codestorywithMIK
2024-03-19Merge In Between Linked Lists | Easy Straight Forward | AMAZON | Leetcode 1669 | codestorywithMIK
2024-03-18Task Scheduler | Easy Intuition | Using Heap | Leetcode 621 | codestorywithMIK
2024-03-17Minimum Deletions to Make String K-Special | 2 Simple Approaches | Leetcode 3085 | codestorywithMIK
2024-03-16Count Substrings Starting and Ending with Given Character | Leetcode 3084 | codestorywithMIK
2024-03-16Shortest Common Supersequence | 3 Approaches | DP On Strings |DP Concepts & Qns 20|codestorywithMIK
2024-03-15Contiguous Array | Using same Pattern Approach | Similar Problems | Leetcode 525
2024-03-15Trie VS Tree
2024-03-14Binary Subarrays With Sum | 2 Approaches | Detailed Explanation | Leetcode 930
2024-03-13Find the Pivot Integer | 5 Approaches | Easy Explanation | Leetcode 2485