Palindrome Linked List (LeetCode 234) | Full solution with trick | Study Algorithms

  Рет қаралды 11,892

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Пікірлер: 34
@dupladupa-gl8lo
@dupladupa-gl8lo Ай бұрын
bro trust me u r a god level teacher bro omg
@sameerkumarsingh8942
@sameerkumarsingh8942 9 ай бұрын
i dont but i get a lot of clarity from your videos , Thanks a lot
@hunorvadasz-perhat6001
@hunorvadasz-perhat6001 Жыл бұрын
Good explanation! Thank you for the great video 😃
@nikoo28
@nikoo28 Жыл бұрын
thank you for subscribing.. :)
@poojakasar4572
@poojakasar4572 Жыл бұрын
explanation is awesome💥💥👍
@matthewzarate8851
@matthewzarate8851 4 ай бұрын
Loved the explanation for both implementations! Thanks Nikhil!
@honey-xr5kp
@honey-xr5kp 6 ай бұрын
Love your videos! Very well explained. When I tried this code though, I received a time limit exceeded error. I'm sure its on my end, but I'm not sure why because as far as I know its the same code and should work.
@nikoo28
@nikoo28 6 ай бұрын
try the code available on github (link in description)
@HemaSanthoshiAkula
@HemaSanthoshiAkula Жыл бұрын
such a clean explanation, i loved it
@infinite639
@infinite639 Жыл бұрын
Why not using collection linkedlist of java Why we are making our own linkedlist ? Why we are making our own tree? Please answer
@bhumikabansal6022
@bhumikabansal6022 Жыл бұрын
your all explanations are awesome
@nikoo28
@nikoo28 Жыл бұрын
Thank you so much 😀
@Hello-l3i
@Hello-l3i 25 күн бұрын
i am not getting ,what if the no.of nodes is odd ???pls explain
@deeptigarg799
@deeptigarg799 6 ай бұрын
When we are doing fast = head and traversed fast to null then why head is not null. Aren't we dealing with the address?
@shubhamgupta8248
@shubhamgupta8248 Жыл бұрын
Not able to understand why i am getting an error when i write while(fast!=null) { if(fast.val!=slow.val) { return false; }
@nikoo28
@nikoo28 Жыл бұрын
compare to the code I have
@naruto_6663
@naruto_6663 8 ай бұрын
so if this answer matters if we write fast != null we will see we have not breaked the linked list in two there is still connection between the 7->2 so that will not be null thats why we write slow != null as slow pointer will point to null 7->null (after the reverse of the list):)
@indrajith2002
@indrajith2002 9 ай бұрын
bro but for odd testcase it doesnt work .lets say we have a testcase 1->2->3->2->1->null according to you slow points to middle 3 , now if we reverse it will become 1->2->3->null ,where fast points to starting 1 .now if start comparing values @ fast and slow upto 2 it will be same after that slow points to 3 but fast points to null .so what to do?
@nikoo28
@nikoo28 9 ай бұрын
It does work, did you try with such a case?
@bhavishyathota6160
@bhavishyathota6160 2 ай бұрын
ok,but what's in case of linkedlist of odd length?
@nikoo28
@nikoo28 2 ай бұрын
The middle element does not matter. 1 4 x 4 1 The middle element x could be anything
@AlgoXperience
@AlgoXperience 11 ай бұрын
i love it
@121sarthkumar4
@121sarthkumar4 5 ай бұрын
when we do fast= head does it start from for head of ex 237732 this value or is it half
@nikoo28
@nikoo28 4 ай бұрын
Can you please elaborate on your example?
@appikeeru5785
@appikeeru5785 3 ай бұрын
Y in his videos very less viewers😢
@rezowanamehjabinlorel1428
@rezowanamehjabinlorel1428 7 ай бұрын
Please make more explanation videos
@nikoo28
@nikoo28 7 ай бұрын
Will do..new video every week 😄 Please share as much possible too 😎
@padmajab2294
@padmajab2294 Жыл бұрын
Nice explanation
@cautioni
@cautioni 5 ай бұрын
please do a longest palindrome in a linked list
@nikoo28
@nikoo28 5 ай бұрын
Will add it to my pipeline of video
@alihaiderzada423
@alihaiderzada423 Жыл бұрын
The stack solution does not work if the pattern is 2 - 3 - 7 - 3 - 2. even tho it is a palindrome
@bhumikabansal6022
@bhumikabansal6022 Жыл бұрын
go with the optimized one
@SaumyaSharma007
@SaumyaSharma007 Жыл бұрын
Hello, what you can do: Traverse entire L. List. (Let Length of LList come out be n) Just push n/2 elements in the stack. Now you can check if n is odd which is your case. Curr will be pointing to -7. So Curr = Curr-> next; Now start comparing left-out L list with stack elements. If n was even. Eg 2 -3 -3 2 Then We would have done nothing. Coz We have already pushed n/2 elements. And Curr will be pointing to the Third element. Now start comparing left-out L list with stack elements. Hope it helps. 😄
@alihaiderzada423
@alihaiderzada423 Жыл бұрын
@@SaumyaSharma007 awesome thanks buddy i will give it ago.. :)
L10. Check if a LinkedList is Palindrome or Not | Multiple Approaches
20:02
когда не обедаешь в школе // EVA mash
00:51
EVA mash
Рет қаралды 4,4 МЛН
Mom had to stand up for the whole family!❤️😍😁
00:39
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 3,7 МЛН
Leetcode 46. Permutations : Introduction to backtracking
10:06
ComputerBread
Рет қаралды 99 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 444 М.
Palindrome Linked List | Live Coding with Explanation | Leetcode - 234
10:30
Algorithms Made Easy
Рет қаралды 10 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 256 М.
How I Mastered Data Structures and Algorithms
10:45
Ashish Pratap Singh
Рет қаралды 205 М.
когда не обедаешь в школе // EVA mash
00:51
EVA mash
Рет қаралды 4,4 МЛН