L14. Detect a loop or cycle in LinkedList | With proof and Intuition

  Рет қаралды 53,390

take U forward

take U forward

7 ай бұрын

Problem Link: tinyurl.com/3rxwup5c
Entire LL Sheet: takeuforward.org/linked-list/...
Check our A2Z DSA Course: takeuforward.org/strivers-a2z...
Please do give us a like, and subscribe to us if you are new to our channel.
Do follow us on our socials: linktr.ee/takeuforward

Пікірлер: 96
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 5 ай бұрын
No one even in paid courses also give the intuition behind the algorithms like you did Sir. You could have earned millions by paid courses but instead you chose to contribute for the greater well of the society. Hats off!
@sakshammisra189
@sakshammisra189 2 сағат бұрын
bro , i am with you in all of your debate , still he is earning heavily due to yt , maybe not particularly this video with 53k views at this point but he has videos with million views too
@adarshjhanitkurukshetra
@adarshjhanitkurukshetra 6 ай бұрын
Whole NIT and IIT follows you ♥, hats off
@AdityaGupta-cx1ej
@AdityaGupta-cx1ej 5 ай бұрын
Bro I am in IIIT-Kottayam we also follow not just IIT and Nit🙂
@frouMagician
@frouMagician 8 күн бұрын
@@AdityaGupta-cx1ej well, he did not say "only" NITs and IITs follow him, did he ?
@bishalkundu7592
@bishalkundu7592 7 ай бұрын
Knew this algorithm but came here to learn the proof ❤ And guess what Striver Bhaiyaa never disappoints ❤
@kamalakannanng4206
@kamalakannanng4206 3 ай бұрын
The whole video is 10/10 but the intuition part is 1000/10. Just Striver things 🔥
@arzooqureshi8821
@arzooqureshi8821 7 ай бұрын
I am so glad i found this channel.The Best!
@divyatejaswinivengada6368
@divyatejaswinivengada6368 4 ай бұрын
Hands down the best explanation I have seen in so many year's , I am forever grateful for such beautiful intuition and explanation
@aryanpinto5105
@aryanpinto5105 6 ай бұрын
The intuition part!🤌💯
@user-ql5pe3xc3p
@user-ql5pe3xc3p 2 ай бұрын
Bro , i write my own bro by seeing your explanation ❤️ You are my God bro 🫂
@_CodeLifeChronicles_
@_CodeLifeChronicles_ Ай бұрын
the best dsa course. i can code myself after the intuition.explanaton is crystal clear
@aruna5869
@aruna5869 6 күн бұрын
big hats off for the intuition part!!!🙌❤❤
@deepakbhatt03
@deepakbhatt03 6 ай бұрын
This is real teaching!
@tanya8353
@tanya8353 3 ай бұрын
Wonderful explanation striver!!! You are really doing an incredible job!!
@_dion_
@_dion_ 4 ай бұрын
the best explanation on the internet.
@hareshnayak7302
@hareshnayak7302 3 ай бұрын
Understood, thanks striver for this amazing video.
@AbhijitSahoo-oc2lz
@AbhijitSahoo-oc2lz 6 ай бұрын
Many many Thanks for your effort Bhaiyaa ❤ you are in those teacher's of my life which i can never forger in my life❤💯
@harshsingh357
@harshsingh357 2 ай бұрын
🙌 Loved the way you explained the problem solution and intuition . Thank you very much .
@shrutishukla6336
@shrutishukla6336 3 ай бұрын
Thankyou Sir for teaching us real problem solving.
@franciskp9117
@franciskp9117 5 ай бұрын
Man you're a GENIUS !!!
@SaqibChoudhary09
@SaqibChoudhary09 4 ай бұрын
Best DSA in YT
@anuplohar23
@anuplohar23 5 ай бұрын
18:25 That's the reason why I preferred Striver's DSA playlist
@tusharyadav5874
@tusharyadav5874 Ай бұрын
Hi, Remember one thing slow and fast pointer will always meet if the ratio b/w speed of slow and fast pointer is greater than 1. There ratio can be in decimal also , But if you want them to meet fast in the loop then optimal speed will be slow = 1 and fast = 2. But if the two pointers move like slow = 3 and fast = 5 then they also meet. It will take multiple cyle but they will eventually meet.
@kapilsolanki6844
@kapilsolanki6844 7 ай бұрын
Striver bhaiya linked list ki sbhi videos jldi se upload kr do , next month interview bhi h😇
@rishabh_pant
@rishabh_pant 7 ай бұрын
All the best brother 🎉
@shreyxnsh.14
@shreyxnsh.14 5 ай бұрын
how did it go?
@rahulmandal4007
@rahulmandal4007 22 күн бұрын
@@shreyxnsh.14 It was ok
@user-ik3qu5uy5e
@user-ik3qu5uy5e 4 ай бұрын
you are great sir ! loads of love ❤
@SimranChetiwal-uy2xn
@SimranChetiwal-uy2xn 7 ай бұрын
Great Striver🤩🤩
@codingp110
@codingp110 Ай бұрын
Awesome Explanation!
@sarangkumarsingh7901
@sarangkumarsingh7901 16 күн бұрын
Awesome content Sir......
@tollytrendzvideos395
@tollytrendzvideos395 Ай бұрын
A great explanation bro....... ❤
@NazeerBashaShaik
@NazeerBashaShaik 2 ай бұрын
Understood, thank you.
@krishnakarule3708
@krishnakarule3708 13 күн бұрын
You are the best!!
@pratyushtripathi1728
@pratyushtripathi1728 6 ай бұрын
Understood 😊
@pritagarwal6389
@pritagarwal6389 15 күн бұрын
very well explained Dek raha ha Binod Kitna easy hota ha DSA.....
@YourCodeVerse
@YourCodeVerse 5 ай бұрын
Understood✅🔥🔥
@user-tk2vg5jt3l
@user-tk2vg5jt3l 4 ай бұрын
Thank you bhaiya
@selene8721
@selene8721 2 ай бұрын
Thank you so much!!
@nrted3877
@nrted3877 17 күн бұрын
Thanks striver
@gaurishaaaa
@gaurishaaaa 5 ай бұрын
wish i could give you 1000 likes at once. Great explaination.
@abhinavkumar6344
@abhinavkumar6344 3 ай бұрын
great way to explain why fast and slow ptointers will collide definitely..🙅
@Abhishekthakur-mg4el
@Abhishekthakur-mg4el 7 ай бұрын
thanks bhai❤
@nayanbramhane8077
@nayanbramhane8077 5 ай бұрын
thanks for telling us the why 😁
@subee128
@subee128 7 ай бұрын
Thanks
@user-or5oz1pk2x
@user-or5oz1pk2x 3 ай бұрын
Thanks A Lot
@karmveersingh1334
@karmveersingh1334 5 ай бұрын
Understood 😇
@shaiksoofi3741
@shaiksoofi3741 15 күн бұрын
thank you
@nayanbramhane8077
@nayanbramhane8077 5 ай бұрын
thanks bro
@chinmayraichur8984
@chinmayraichur8984 4 ай бұрын
Understood!
@NARUTOUZUMAKI-bk4nx
@NARUTOUZUMAKI-bk4nx 5 ай бұрын
Understooood
@sayantanpoddar5428
@sayantanpoddar5428 3 ай бұрын
Understood!!
@nehapimpalkar396
@nehapimpalkar396 5 ай бұрын
understood!
@SibiRanganathL
@SibiRanganathL 3 ай бұрын
Understood
@hardikpatel352
@hardikpatel352 Ай бұрын
understood
@BarrytheClipper
@BarrytheClipper Ай бұрын
If you still confused in H T approach then Imagine, the distance between Hare and Tortoise is 5m. So according to logic we move Tortoise by 1, the distance will be 5m and Hare by 2. So them the overall distance will be 6-2 =4m Our distance got reduced by 4m And if you keep continuing the approach eventually our distance will be zero And the same approach might work in 3. Bit it's depend on luck Like 5+1 = 6. Then 6-3 = 3m Again, 3+1= 4. Them 4-3 = 1m Again, 1-1 = 2. Them 2-3 = -1 m Overlapping.....
@manansarraf73
@manansarraf73 8 күн бұрын
GOD OF DSA->STRIVER
@rockstarCoolz
@rockstarCoolz Ай бұрын
Thx sir ,can u pls bring string playlist sir pls pls pls😅😅 i m excited for it...
@SunnyKumar-dw9ze
@SunnyKumar-dw9ze 7 ай бұрын
👍
@hatkereacts
@hatkereacts 6 ай бұрын
Striver only had one issue that could be heard from a few that his lectures are not beginer friendly. Now that's all the past , it is settled. This is BEST content to exist for all the STRIVERS out there to learn dsa period.! No matter how much dsa u have done earlier even if u r a beginer the A2Z sheet is hands down the best+
@ashishpradhan6250
@ashishpradhan6250 18 күн бұрын
underestood
@mayankshakya9200
@mayankshakya9200 7 ай бұрын
17:44 correction if we move slow by 1 and fast by 2,3,4,5 etc we still collide and get the answer i ve prove it if you want you can increment fast by >=2 by having the appropriate while check
@shreyxnsh.14
@shreyxnsh.14 5 ай бұрын
so that means what he said is wrong?
@shreyxnsh.14
@shreyxnsh.14 5 ай бұрын
3,4,5 wont work if the list has just 2 elements
@mayankshakya9200
@mayankshakya9200 5 ай бұрын
@@shreyxnsh.14 kind of yes or we can say that he hasnt explored about that…
@Shivi32590
@Shivi32590 26 күн бұрын
Thank you !🌄
@rahuldwivedi4758
@rahuldwivedi4758 6 ай бұрын
Or we can also say, if fast->next == slow return true; to optimize by one step.
@tejastrivedi2023
@tejastrivedi2023 6 ай бұрын
While putting the condition fast!=NULL should come before fast->next != NULL,if you do vice versa then it will show pointer error
@user-ot1rd8hd3d
@user-ot1rd8hd3d 5 ай бұрын
undersood
@user-gw5kf6ih9s
@user-gw5kf6ih9s 3 ай бұрын
relative motion yaad agaya
@dineshkumarrg4894
@dineshkumarrg4894 4 ай бұрын
13:40 will know the intuition behind why slow and fast pointer will meet
@4everachyut
@4everachyut Ай бұрын
Is it necessary to increase the fast pointer only by 2? What if we increased it by 3 or 4? Will it still meet the slow pointer?
@HarshMishra-hp2lt
@HarshMishra-hp2lt Ай бұрын
Can we also use unordered_set instead of map?
@rahuldwivedi4758
@rahuldwivedi4758 6 ай бұрын
while(fast !=null){ fast = fast->next; fast = fast -> next; slow = slow ->next; If(fast->next == slow) return true; } return false;
@VIJAYSHARMA-dh6vo
@VIJAYSHARMA-dh6vo 6 ай бұрын
instead of using fast->next 2 times you can simply write fast->next->next :)
@rahuldwivedi4758
@rahuldwivedi4758 6 ай бұрын
@@VIJAYSHARMA-dh6vo I know :). But my intention was to make it more obvious that fast is taking two steps when slow just takes one. Also I wanted to avoid that extra ugly check in while, ie, && fast->next->next != null (just a personal preference.)
@peterfromengland8663
@peterfromengland8663 4 ай бұрын
what if the length of LL is 1 or 2?? will this code throw a error??
@mananpareek6089
@mananpareek6089 Ай бұрын
More efficient time and space complexity solution bool hasCycle(ListNode *head) { if(head==NULL || head->next==NULL)return false; ListNode*temp=head; while(temp) { if(temp->val==1e8)return true; temp->val=1e8; temp=temp->next; } return false; }
@iamnoob7593
@iamnoob7593 4 ай бұрын
US
@ManasNandMohan
@ManasNandMohan 6 ай бұрын
Your explanation is op 💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥 💥 ❤‍🩹
@rajputvanrajsinh9527
@rajputvanrajsinh9527 3 ай бұрын
In your old website you given those links but now what you have given in your link is not good videos
@thesumitkumar0
@thesumitkumar0 5 ай бұрын
Time Complexity of this ?
@abhijitjha4409
@abhijitjha4409 7 күн бұрын
ListNode* temp = head; int i = 0; while(temp){ if(temp && temp->val == INT_MAX) return true; temp->val = INT_MAX; temp = temp->next; } return false; Can this be a solution??? can i tell this to the interviwer ?
@user-sl9xm3cm3p
@user-sl9xm3cm3p Ай бұрын
Why not use a set instead of map?
@adityaasthana8758
@adityaasthana8758 Ай бұрын
When we will move slow by 1 and fast by 3..then also they will collide....Yrr I don't understand why we are moving slow by 1 and fast by 2..pls anyone can help???
@cenacr007
@cenacr007 4 ай бұрын
us
@user-kn4zc2gt3r
@user-kn4zc2gt3r 13 күн бұрын
please use some hindi words please so that north indian student understand easily
@codeman3828
@codeman3828 5 ай бұрын
Understood
@surbhigupta5777
@surbhigupta5777 Ай бұрын
US
@pradipkumarmukhi
@pradipkumarmukhi Ай бұрын
Understood
@dewanandkumar8589
@dewanandkumar8589 Ай бұрын
Understood
@abhishekprasad010
@abhishekprasad010 Ай бұрын
Understood
@vedantnaikwadi5394
@vedantnaikwadi5394 Ай бұрын
Understood
@himanshidafouty347
@himanshidafouty347 23 күн бұрын
Understood
@ig_strawhats_
@ig_strawhats_ Ай бұрын
Understood
L15. Find the length of the Loop in LinkedList
14:01
take U forward
Рет қаралды 35 М.
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 107 МЛН
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 25 МЛН
the TRUTH about C++ (is it worth your time?)
3:17
Low Level Learning
Рет қаралды 637 М.
#CAT - July Schedule || 143 days left #vlog #crackcat #motivation
11:24
L9. Reverse a LinkedList | Iterative and Recursive
32:42
take U forward
Рет қаралды 89 М.
MINER POISON NEVER DIES!!!!!!!!!!
17:47
Ian77 - Clash Royale
Рет қаралды 68 М.
I solved 541 Leetcode problems. But you need only 150.
7:42
Sahil & Sarra
Рет қаралды 2,3 МЛН
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 617 М.
Time and Space Complexity - Strivers A2Z DSA Course
35:16
take U forward
Рет қаралды 472 М.
L13. Find the middle element of the LinkedList | Multiple Approaches
14:37