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

  Рет қаралды 100,254

take U forward

take U forward

Күн бұрын

Пікірлер
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 10 ай бұрын
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 4 ай бұрын
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
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 4 ай бұрын
@@sakshammisra189 Yes. But he is not only earning money. He is earning prayers and blessings of millions of students like us. He is helping even foreign countries students as you won't see much videos from them. Indian KZbinrs took teaching to the next level through KZbin.Thousands of us will get inspired to contribute like him when we become successful and have the opportunity. That's how he is shaping our minds.
@priyanshugupta7840
@priyanshugupta7840 3 ай бұрын
@@sakshammisra189 Atleast, he is redeeming what he earns with his efforts and generosity
@kamalakannanng4206
@kamalakannanng4206 7 ай бұрын
The whole video is 10/10 but the intuition part is 1000/10. Just Striver things 🔥
@bishalkundu7592
@bishalkundu7592 Жыл бұрын
Knew this algorithm but came here to learn the proof ❤ And guess what Striver Bhaiyaa never disappoints ❤
@adarshjhanitkurukshetra
@adarshjhanitkurukshetra 11 ай бұрын
Whole NIT and IIT follows you ♥, hats off
@AdityaGupta-cx1ej
@AdityaGupta-cx1ej 10 ай бұрын
Bro I am in IIIT-Kottayam we also follow not just IIT and Nit🙂
@frouMagician
@frouMagician 4 ай бұрын
@@AdityaGupta-cx1ej well, he did not say "only" NITs and IITs follow him, did he ?
@divyatejaswinivengada6368
@divyatejaswinivengada6368 9 ай бұрын
Hands down the best explanation I have seen in so many year's , I am forever grateful for such beautiful intuition and explanation
@_CodeLifeChronicles_
@_CodeLifeChronicles_ 6 ай бұрын
the best dsa course. i can code myself after the intuition.explanaton is crystal clear
@WorstinJava
@WorstinJava 7 ай бұрын
Bro , i write my own bro by seeing your explanation ❤️ You are my God bro 🫂
@aryanpinto5105
@aryanpinto5105 11 ай бұрын
The intuition part!🤌💯
@arzooqureshi8821
@arzooqureshi8821 11 ай бұрын
I am so glad i found this channel.The Best!
@mananshah3248
@mananshah3248 11 күн бұрын
10:15 You don't need to do the whole odd even thing. Just think of relative velocity - it's 2-1 = 1. Since it's an infinite loop, think of slow as just standing still, and fast moving with velocity of 1 relative to slow. Eventually it's gonna round up and reach slow.
@tusharyadav5874
@tusharyadav5874 6 ай бұрын
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.
@priyanshugupta7840
@priyanshugupta7840 3 ай бұрын
Can you please explain how that works?
@anuplohar23
@anuplohar23 9 ай бұрын
18:25 That's the reason why I preferred Striver's DSA playlist
@arielluquer8274
@arielluquer8274 4 ай бұрын
Awesome video! I was doubting you'd actually explain the intuition in an intuitive way but you did it, thank you!!
@BarrytheClipper
@BarrytheClipper 5 ай бұрын
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.....
@hareshnayak7302
@hareshnayak7302 7 ай бұрын
Understood, thanks striver for this amazing video.
@deepakbhatt03
@deepakbhatt03 11 ай бұрын
This is real teaching!
@ishantsharma8139
@ishantsharma8139 3 ай бұрын
You are best teacher on KZbin ❤
@_dion_
@_dion_ 9 ай бұрын
the best explanation on the internet.
@manishmahajan6094
@manishmahajan6094 3 ай бұрын
What a clarity !!! God level explanation at end
@qwarlockz8017
@qwarlockz8017 2 ай бұрын
I am having so much fun with your videos. They are so clear and interesting. You are doing a great job!
@tanya8353
@tanya8353 8 ай бұрын
Wonderful explanation striver!!! You are really doing an incredible job!!
@harshsingh357
@harshsingh357 6 ай бұрын
🙌 Loved the way you explained the problem solution and intuition . Thank you very much .
@SaqibChoudhary09
@SaqibChoudhary09 9 ай бұрын
Best DSA in YT
@shamanthhegde2820
@shamanthhegde2820 3 ай бұрын
Your at a whole new level
@aman_deep21
@aman_deep21 3 ай бұрын
Great explanation of the intuition ❤
@AbhijitSahoo-oc2lz
@AbhijitSahoo-oc2lz 10 ай бұрын
Many many Thanks for your effort Bhaiyaa ❤ you are in those teacher's of my life which i can never forger in my life❤💯
@shrutishukla6336
@shrutishukla6336 7 ай бұрын
Thankyou Sir for teaching us real problem solving.
@RajNamdev_19
@RajNamdev_19 3 ай бұрын
Understood very well. I just love the way you teach. Love you Striver Bro ❤ One day or other I will meet you in the Google office or somewhere else and I will thank you personally by hugging you tight Bhai ❤
@aruna5869
@aruna5869 4 ай бұрын
big hats off for the intuition part!!!🙌❤❤
@Testing-ts4qq
@Testing-ts4qq 4 күн бұрын
Thank you ❤❤😊 the intuition part was crazy. Loved it really.
@TS-oj3vd
@TS-oj3vd 11 күн бұрын
intuition explanation was on point.
@pritagarwal6389
@pritagarwal6389 5 ай бұрын
very well explained Dek raha ha Binod Kitna easy hota ha DSA.....
@abhinavkumar6344
@abhinavkumar6344 8 ай бұрын
great way to explain why fast and slow ptointers will collide definitely..🙅
@kapilsolanki6844
@kapilsolanki6844 Жыл бұрын
Striver bhaiya linked list ki sbhi videos jldi se upload kr do , next month interview bhi h😇
@rishabh_pant
@rishabh_pant 11 ай бұрын
All the best brother 🎉
@shreyxnsh.14
@shreyxnsh.14 9 ай бұрын
how did it go?
@rahulmandal4007
@rahulmandal4007 5 ай бұрын
@@shreyxnsh.14 It was ok
@anindyapaul9735
@anindyapaul9735 3 ай бұрын
For which company?​@@rahulmandal4007
@shivamdeore5556
@shivamdeore5556 2 ай бұрын
Man you are great, simply great!!!
@franciskp9117
@franciskp9117 10 ай бұрын
Man you're a GENIUS !!!
@PrashantSaxena-e4c
@PrashantSaxena-e4c 2 ай бұрын
Easier Solution could be : class Solution { public: bool hasCycle(ListNode *head) { ListNode* temp=head; while(temp!=nullptr){ if(temp->val==1e7){ return true; } temp->val=1e7; temp=temp->next; } return false; } };
@sarangkumarsingh7901
@sarangkumarsingh7901 5 ай бұрын
Awesome content Sir......
@SimranChetiwal-uy2xn
@SimranChetiwal-uy2xn Жыл бұрын
Great Striver🤩🤩
@mayankshakya9200
@mayankshakya9200 Жыл бұрын
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 9 ай бұрын
so that means what he said is wrong?
@shreyxnsh.14
@shreyxnsh.14 9 ай бұрын
3,4,5 wont work if the list has just 2 elements
@mayankshakya9200
@mayankshakya9200 9 ай бұрын
@@shreyxnsh.14 kind of yes or we can say that he hasnt explored about that…
@tejastrivedi2023
@tejastrivedi2023 11 ай бұрын
While putting the condition fast!=NULL should come before fast->next != NULL,if you do vice versa then it will show pointer error
@manansarraf73
@manansarraf73 4 ай бұрын
GOD OF DSA->STRIVER
@tollytrendzvideos395
@tollytrendzvideos395 5 ай бұрын
A great explanation bro....... ❤
@codingp110
@codingp110 5 ай бұрын
Awesome Explanation!
@NonameNoname-f2t
@NonameNoname-f2t 9 ай бұрын
you are great sir ! loads of love ❤
@monish0075
@monish0075 Ай бұрын
brw there is no videos on string please upload the video it will be very useful for us please upload it Asap
@gaurishaaaa
@gaurishaaaa 10 ай бұрын
wish i could give you 1000 likes at once. Great explaination.
@learning_trespasser
@learning_trespasser 9 ай бұрын
thanks for telling us the why 😁
@seeingsee6593
@seeingsee6593 Ай бұрын
you are genius i love you thank you so much
@gautamsaxena4647
@gautamsaxena4647 11 күн бұрын
understood bhaiya
@rahuldwivedi4758
@rahuldwivedi4758 10 ай бұрын
while(fast !=null){ fast = fast->next; fast = fast -> next; slow = slow ->next; If(fast->next == slow) return true; } return false;
@VIJAYSHARMA-dh6vo
@VIJAYSHARMA-dh6vo 10 ай бұрын
instead of using fast->next 2 times you can simply write fast->next->next :)
@rahuldwivedi4758
@rahuldwivedi4758 10 ай бұрын
@@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.)
@krishnakarule3708
@krishnakarule3708 5 ай бұрын
You are the best!!
@pratyushtripathi1728
@pratyushtripathi1728 11 ай бұрын
Understood 😊
@rahuldwivedi4758
@rahuldwivedi4758 10 ай бұрын
Or we can also say, if fast->next == slow return true; to optimize by one step.
@nrted3877
@nrted3877 5 ай бұрын
Thanks striver
@hatkereacts
@hatkereacts 11 ай бұрын
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+
@moneeb-ur-rahman7
@moneeb-ur-rahman7 Ай бұрын
Awesome!
@mananpareek6089
@mananpareek6089 5 ай бұрын
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; }
@rockstarCoolz
@rockstarCoolz 5 ай бұрын
Thx sir ,can u pls bring string playlist sir pls pls pls😅😅 i m excited for it...
@dineshkumarrg4894
@dineshkumarrg4894 8 ай бұрын
13:40 will know the intuition behind why slow and fast pointer will meet
@Learnprogramming-q7f
@Learnprogramming-q7f 9 ай бұрын
Thank you bhaiya
@NazeerBashaShaik
@NazeerBashaShaik 7 ай бұрын
Understood, thank you.
@shubhamchaudhary8688
@shubhamchaudhary8688 2 ай бұрын
Intution - ground mein do ladke bhaag rahe ek dusre se tez hai...aisa koi na koi point to aega hi na jab tez wala ladka dhere wale ko pakad lega.
@YourCodeVerse
@YourCodeVerse 10 ай бұрын
Understood✅🔥🔥
@shaiksoofi3741
@shaiksoofi3741 5 ай бұрын
thank you
@NARUTOUZUMAKI-bk4nx
@NARUTOUZUMAKI-bk4nx 10 ай бұрын
Understooood
@DeepakPatel-d5v
@DeepakPatel-d5v 7 ай бұрын
Thanks A Lot
@codeman3828
@codeman3828 9 ай бұрын
Understood
@subee128
@subee128 11 ай бұрын
Thanks
@ashishpradhan6250
@ashishpradhan6250 5 ай бұрын
underestood
@YPZanzarukiya
@YPZanzarukiya 4 ай бұрын
understand
@selene8721
@selene8721 7 ай бұрын
Thank you so much!!
@hardikpatel352
@hardikpatel352 6 ай бұрын
understood
@chinmayraichur8984
@chinmayraichur8984 9 ай бұрын
Understood!
@ArpitPatel-k4s
@ArpitPatel-k4s 13 күн бұрын
Bhaiya itna khatarnak nhi padna h sb dar jaye
@learning_trespasser
@learning_trespasser 9 ай бұрын
thanks bro
@HarshMishra-hp2lt
@HarshMishra-hp2lt 6 ай бұрын
Can we also use unordered_set instead of map?
@XS_01
@XS_01 4 ай бұрын
bool hasCycle(ListNode *head) { if(head == NULL) return false; ListNode* temp = head; int n = 10000; //given contraint for(int i=0; inext == NULL){ return false; } temp = temp->next; } return true; } big brain move
@anikesh001-qwe
@anikesh001-qwe 4 ай бұрын
@YashNagaria
@YashNagaria 7 ай бұрын
relative motion yaad agaya
@4everachyut
@4everachyut 5 ай бұрын
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?
@anindyapaul9735
@anindyapaul9735 3 ай бұрын
See the video completely. U will get to know
@nehapimpalkar396
@nehapimpalkar396 10 ай бұрын
understood!
@Abhishekthakur-mg4el
@Abhishekthakur-mg4el Жыл бұрын
thanks bhai❤
@YATHARTHBHARDWAJ-y8m
@YATHARTHBHARDWAJ-y8m 10 ай бұрын
undersood
@elco7956
@elco7956 4 ай бұрын
🐐
@SunnyKumar-dw9ze
@SunnyKumar-dw9ze 11 ай бұрын
👍
@rajputvanrajsinh9527
@rajputvanrajsinh9527 8 ай бұрын
In your old website you given those links but now what you have given in your link is not good videos
@test-nature
@test-nature 2 ай бұрын
I am struggling with chatgpt why move 1 and why move 2. then I was jump to this video
@saranshbhole8500
@saranshbhole8500 3 ай бұрын
Wrong Answer 15 / 29 testcases passed Editorial Inputhead =[1,2] pos = -1 Use Testcase Output=true Expected=false the above test case fails to do so what about this condition?
@peterfromengland8663
@peterfromengland8663 8 ай бұрын
what if the length of LL is 1 or 2?? will this code throw a error??
@abhijitjha4409
@abhijitjha4409 4 ай бұрын
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 ?
@thesumitkumar0
@thesumitkumar0 9 ай бұрын
Time Complexity of this ?
@MyselfNothing-t5c
@MyselfNothing-t5c 3 ай бұрын
what if it has same elements ?
@DhineshKaviraaj
@DhineshKaviraaj 5 ай бұрын
Why not use a set instead of map?
@iamnoob7593
@iamnoob7593 8 ай бұрын
US
@SamyakSharma-oy1bv
@SamyakSharma-oy1bv 20 күн бұрын
respect++;
@cenacr007
@cenacr007 8 ай бұрын
us
@adityaasthana8758
@adityaasthana8758 6 ай бұрын
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???
@nishantgupta5015
@nishantgupta5015 4 ай бұрын
If we follow, slow by by 1 and fast by 3 the resultant reduction between them will be 2 , and consider if initial b/w tem is 7 the follow will like this 7 - 5 - 3 - 1 - (-1)... No collision of them
@adityaasthana8758
@adityaasthana8758 3 ай бұрын
Thanks @@nishantgupta5015
@ManasNandMohan
@ManasNandMohan 11 ай бұрын
Your explanation is op 💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥💥 💥 ❤‍🩹
@KAMLESHGURJAR-y3z
@KAMLESHGURJAR-y3z 5 ай бұрын
please use some hindi words please so that north indian student understand easily
L15. Find the length of the Loop in LinkedList
14:01
take U forward
Рет қаралды 61 М.
132. Palindrome Partitioning II  Leetcode
14:46
GET SDE READY
Рет қаралды 3,5 М.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 24 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 3 МЛН
What type of pedestrian are you?😄 #tiktok #elsarca
00:28
Elsa Arca
Рет қаралды 36 МЛН
ML Was Hard Until I Learned These 5 Secrets!
13:11
Boris Meinardus
Рет қаралды 341 М.
L10. Check if a LinkedList is Palindrome or Not | Multiple Approaches
20:02
L13. Find the middle element of the LinkedList | Multiple Approaches
14:37
L12. Find the intersection point of Y LinkedList
32:05
take U forward
Рет қаралды 81 М.
Pascal Triangle | Finding nCr in minimal time
26:45
take U forward
Рет қаралды 283 М.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН