Detect & Remove Cycle in a Linked List | Floyd's Cycle Detection Algorithm | DSA-One Course #39

Поділитися
Вставка
  • Опубліковано 11 жов 2024
  • Hey guys, In this video, We're going to learn Floyd's cycle Detection Algorithm. This algorithm is used to detect and remove cycle in a Linked List.
    Code: www.geeksforge...
    🥳 Join our Telegram Community:
    Telegram channel: telegram.me/re...
    Telegram group: telegram.me/ds...
    🚀 Follow me on:
    Instagram: / anuj.kumar.sharma
    Linkedin: / sharma-kumar-anuj
    Twitter: / realanujbhaiya
    💸 Use coupon code ANUJBHAIYA on GeeksforGeeks to avail discounts on courses!
    📚 Complete DSA Playlist: • DSA-One Course - The C...
    Complete Android Development Playlist: • Android Development Tu...
    Hashtags:
    #anujbhaiya #dsaone
    Ignore these tags:
    detect
    detect lying
    detect lyin
    dust detect
    detect lies
    detect movie
    detect tempo
    detect fakes
    detect liars
    dyson v15 detect
    detect short film
    detect short movie
    how to detect liars
    dewalt power detect
    dyson v12 detect slim
    how to detect baloney
    how to detect deception
    detect independent film
    detect telugu short film
    how to detect dark matter
    dyson v15 detect inceleme
    detect the honest officer
    how to detect counterfeit
    linked list
    linked list in c
    linked list conept
    linked lists
    linked list in hindi
    linked list in python
    linked list examples
    linked list in c programming
    c programming for beginners
    beginners
    c tutorial for beginners
    stock market for beginners
    sql for beginners
    beginner
    beginner chinese
    it beginner course
    beginner in coding
    apis for beginners
    investing for beginners
    beginner sewing tips
    sql beginners
    beginner ds algo
    c programming for begineers

КОМЕНТАРІ • 303

  • @ruchitachandel2348
    @ruchitachandel2348 2 роки тому +60

    I really like those who taught concepts in Hindi. Becz being an Indian jitne clarity Hindi me aate hai utne English me kabhi nahi aate. English me sirf concept samagh aata hai or Hindi me concept ghus jaata hai.. Thanks for making such a good content.

  • @nimishnandwana1085
    @nimishnandwana1085 2 роки тому +7

    Your dry run technique is the best bro.

  • @manishkumargupta8677
    @manishkumargupta8677 2 роки тому +1

    Aisi explaination with proof mai pahli baar dekh raha hun
    Thank you very much bhaiya

  • @khudkikhoz
    @khudkikhoz 3 роки тому +2

    Sukriya bhai 😍 itna regular ho kr toh padh b nahi paate jitna regularly videos aa rhe h, Tx for ur time bhai.

  • @danishuddin9752
    @danishuddin9752 2 роки тому +4

    just wow! thank you very much for making DSA easy comfortable and lovable!

  • @debasishphukon5345
    @debasishphukon5345 2 роки тому +1

    Very Nice Explanation,
    For removing the loop, we can put a condition in the while loop without maintaining another pointer
    while(start->next != meet->next)
    {
    start = start->next;
    meet=meet->next;
    }
    meet->next = NULL;
    This is should remove the loop

  • @arshadjaved8136
    @arshadjaved8136 3 роки тому +8

    Please add more interview questions cover all dsa topics as fast as possible..I am following from ur course java for placements .I am unable to find This type of teaching . Please add more videos fast my placements are running in my clg🙏🙏..and thanks so much for ur contribution ❤️❤️

    • @Hrit
      @Hrit 2 роки тому

      Exactly this series is one of the best on youtube

  • @shivamgupta-ch8kw
    @shivamgupta-ch8kw Рік тому +1

    Best explaination on the youtube...Thank you bhaiyaaaaaa

  • @sanketgoel6453
    @sanketgoel6453 2 роки тому +4

    this dsa-algo course is really helpful , if possible create more videos like this to solve the classical question of dsa

  • @preranaramteke5908
    @preranaramteke5908 2 роки тому +3

    Thanks Anuj Bhaiya,For Making DSA Easy to Learn

  • @gpavansai7207
    @gpavansai7207 Рік тому

    Thank You Anuj Bhaiya, now I am clear with Floyd's Cycle Detection Algorithm. :)

  • @DipsOfficial802
    @DipsOfficial802 Рік тому +2

    Thank u Anuj Bhaiya

  • @sakshi07222
    @sakshi07222 Рік тому +1

    Best explanation ever got for this problem

  • @kartikkusmude9008
    @kartikkusmude9008 Рік тому +1

    Best explanation for this question

  • @cliffmathew
    @cliffmathew Рік тому

    Thank you. You have done a great job explaining this. Many other videos I saw (mostly in English) does not do a good job of explaining why the start of the cycle node will be the meeting point after the slow pointer is reset back to start of the list.

  • @Kunalkekaram
    @Kunalkekaram 2 місяці тому

    bhaiya kya tagda dry run krke smjhaya hai mja hi aagya

  • @BRSanush
    @BRSanush 2 роки тому +1

    Crystal Clear Explaination!
    Thank you so much...

  • @iti_koookie9678
    @iti_koookie9678 2 роки тому +3

    Thank you so much It was so helpful...
    Just keep going 👍

  • @naiduaravind4641
    @naiduaravind4641 2 роки тому +1

    Thank you very much brother, I am in lot of confusion with this "linked list cycle check". Your video helped me to understand in a better way and the way of teaching is simply amazzzzzzing.

  • @tejaslomate9214
    @tejaslomate9214 Рік тому +2

    yes, it is very helpful sir..

  • @BhaktiPath-gk6fo
    @BhaktiPath-gk6fo Рік тому

    Best Video in UA-cam till date.

  • @pranjalnama2420
    @pranjalnama2420 2 роки тому +2

    thank you so much sir i was struggling to understand the second proof but you made it clear. ❤

  • @RohitKumar-nb8qe
    @RohitKumar-nb8qe 2 місяці тому

    It was simply awesome and crystal clear..

  • @roopeshverma9719
    @roopeshverma9719 8 місяців тому

    Thanks sir, the proof was the simplest explaination ever!

  • @good114
    @good114 2 роки тому +1

    Thank you Sir💕❤️❤️💕

  • @moshoyab4964
    @moshoyab4964 3 роки тому

    Bhaiya ye course complete kerna bht acha course h very useful h or thoda jaldi jaldi videos dalo awesome course h ♥️♥️♥️

  • @kondurisaivarshath686
    @kondurisaivarshath686 4 місяці тому

    YES,IT WAS HELPFUL TQ Anuj Bhaiya

  • @MOHAMMEDKHALANDER-g1c
    @MOHAMMEDKHALANDER-g1c 10 місяців тому

    Next level 💯 👌 bhai (bro) , I just love the way how you proved that. Literally great 👍 explanation 👏

  • @kishandwivedi2444
    @kishandwivedi2444 3 роки тому

    Tagda explanation bhaiya ji
    Bs isi trh aur saare problems ki vdo daalte rho

  • @anuragchatterjee241
    @anuragchatterjee241 3 роки тому +3

    awesome explanation bhaiya 😀

  • @ananyasiingh21
    @ananyasiingh21 6 місяців тому +1

    Just give an additional if statement to handle the null pointer error in the detectCycle function.

  • @swethakare429
    @swethakare429 2 роки тому +1

    Easy to understand..very nice I am following all ur lectures...!!!

  • @nitinanand1092
    @nitinanand1092 Рік тому +1

    thx bhaiya ur great and here is my solution to remove cycle :-
    public static void removeCycle(Node node, Node head) {
    LinkedList_copied list = new LinkedList_copied();
    if(node == null || node.next == null) {
    return;
    }
    Node curr = head;
    Node ptr = node;
    Node prev = null;
    while(curr != ptr) {
    prev = ptr;
    ptr = ptr.next;
    curr = curr.next;
    }
    prev.next = null;
    }

  • @gouravrawat6476
    @gouravrawat6476 Місяць тому

    Amazing and Best explanation

  • @abd11868
    @abd11868 2 роки тому +2

    Sir I don't think ki slow wala pointer ek se zyda cycle lagyega.... kyu ki jab wo cycle ki starting point pr reach krega us time "fast pointer" to "slow pointer" ke beech ka gap N step hoga, and N

  • @levi-lb6dp
    @levi-lb6dp 2 роки тому +2

    Thanks ❤️

  • @arshadahmed4951
    @arshadahmed4951 2 роки тому +1

    👍 YES, IT WAS HELPFUL. THANKYOU SO MUCH FOR SHARING YOUR KNOWLEDGE WITH US. 🙏🙏🔥🔥🔥

  • @ravikumar4870
    @ravikumar4870 Рік тому

    YES, IT WAS HELPFUL. THANKYOU SO MUCH FOR SHARING YOUR KNOWLEDGE WITH US.

  • @mindbehaviour9195
    @mindbehaviour9195 2 роки тому

    Maja aa gaya bhai, best video on linkedlist

  • @yashjadhav6838
    @yashjadhav6838 2 роки тому +1

    Jod! explanation

  • @shivamchouhan8426
    @shivamchouhan8426 2 роки тому

    your explain's skill really good , i got this linked list problem .Thanks keep contniue.

  • @cricketind8830
    @cricketind8830 2 роки тому +2

    Yes, very helpful

  • @anjalitehlani4114
    @anjalitehlani4114 3 роки тому +14

    So helpful🤗 Thank you❤️

  • @s.g.prajapati3597
    @s.g.prajapati3597 2 роки тому +2

    The idea was helpful!

  • @shivamKumar-pv7gz
    @shivamKumar-pv7gz 2 роки тому +1

    Wonderful explanation bahiya

  • @rohan8758
    @rohan8758 8 місяців тому

    Nice explanation Anuj Bhaiyan ji

  • @everymaterialforstudy4893
    @everymaterialforstudy4893 2 роки тому

    Thank you sir your teaching method is amazing its really helpful to understand the concept of
    dsa

  • @arifsaleem-7377
    @arifsaleem-7377 7 місяців тому

    wonderful explanation

  • @aryansinha1818
    @aryansinha1818 2 роки тому

    Bahut se bhi uppppar helpful

  • @JiGLifyy
    @JiGLifyy 3 роки тому +2

    Really helping video bhiya...keep uploading...placement season is going on . (tier 3 cllg )😅

  • @mohammedsayeed4876
    @mohammedsayeed4876 3 роки тому +1

    What a mind blowing and easy explanation

  • @amitkumarlkr
    @amitkumarlkr 2 роки тому +2

    Great 😃 explanation thank you 😊

  • @Rohitislampur
    @Rohitislampur 9 місяців тому +2

    The equation should be
    A + B = (n-2m) * (B+C)
    instead of
    A + B = (n-m) * (B+C)

  • @sanjayguptab.r1899
    @sanjayguptab.r1899 4 місяці тому +1

    Yes it was helpful

  • @noormaaz
    @noormaaz 2 роки тому

    Big Yes! Apne naya sekha diya

  • @akhilballa8320
    @akhilballa8320 Рік тому

    Veryy much helpful bro...thank you 🙇🙇

  • @eddiepulaski237
    @eddiepulaski237 Рік тому

    Yes, It was very very helpful

  • @ThisAmit
    @ThisAmit 11 місяців тому

    Yes it was helpful. Thank you.

  • @atharvshelgaonkar4694
    @atharvshelgaonkar4694 3 роки тому +2

    Yes video was helpful 😃

  • @pratikchakraborty6999
    @pratikchakraborty6999 3 роки тому +6

    Bhaiyaa please upload more project bases learning videos on android development playlist. Earlier 5 projects were awesome.

  • @nargisp434
    @nargisp434 2 роки тому

    yes it is very very very helpful..plz make video on some more question

  • @shaikaqib3496
    @shaikaqib3496 2 роки тому +1

    YES, IT WAS HELPFUL

  • @mritunjay7065
    @mritunjay7065 2 роки тому

    Simple and best explanation !

  • @Knowledgeduniya1432
    @Knowledgeduniya1432 2 роки тому

    Aww thanks bhaiya ji (sir)♥️🙏🏻

  • @kartikpatidar3378
    @kartikpatidar3378 2 роки тому +2

    Yes

  • @mohdumar6990
    @mohdumar6990 2 роки тому

    bhot bdiya mzaa aagya bhaiya

  • @ravikantmaurya1979
    @ravikantmaurya1979 3 роки тому

    I saw your first video and you got a subscriber....

  • @bishalkundu7592
    @bishalkundu7592 2 роки тому +4

    class Solution
    {
    //Function to remove a loop in the linked list.
    public static void removeLoop(Node head){
    // code here
    // remove the loop without losing any nodes
    Node slow,fast;
    slow=fast=head;
    while(fast!=null && fast.next!=null){
    fast=fast.next.next;
    slow=slow.next;
    if(slow==fast){
    break;
    }
    }
    if(fast==null || fast.next==null) return;
    if(slow==head){ // If the intersection is in the 1st node itself
    while(slow.next!=head){
    slow=slow.next;
    }
    slow.next=null;
    return;
    }
    Node curr=head,prev=slow;
    while(slow!=curr){
    prev=slow;
    slow=slow.next;
    curr=curr.next;
    }
    prev.next=null;
    }
    }
    This is the actual code for those who needs it!

  • @anjaligoyal8106
    @anjaligoyal8106 2 роки тому +1

    Very helpful

  • @srishtychoudhary7750
    @srishtychoudhary7750 2 роки тому

    yes, it was helpful. Great Explanation

  • @Ak-in5cu
    @Ak-in5cu 2 роки тому

    bhaiya yaar matlab maza hi aa gya

  • @sudhanshudwivedi9610
    @sudhanshudwivedi9610 3 роки тому +2

    It was veryyyyyyy helpful❤❤✨ ye course jaldi jaldi complete kra dijiye bhaiya!🙂
    please

  • @mruduladdipalli5417
    @mruduladdipalli5417 2 роки тому

    Ek Number Bhai

  • @Sandeep_Kumar2022
    @Sandeep_Kumar2022 6 місяців тому

    Yes, helpful video ❤❤

  • @ramankr0022
    @ramankr0022 Рік тому

    extremely helpful. thanks.

  • @bharatmakkar9706
    @bharatmakkar9706 Рік тому

    Clear-cut explanation😃

  • @saniyapathan8968
    @saniyapathan8968 4 місяці тому +1

    Best!!

  • @blackwolfkills
    @blackwolfkills 2 роки тому

    Great explaination

  • @SunoTohSahi
    @SunoTohSahi 2 роки тому

    gazab bhaiya gazab 🔥🔥🔥.
    !!!!!!!!!!!

  • @jayeshsingh7764
    @jayeshsingh7764 2 роки тому +2

    YES

  • @anupchaudhary4253
    @anupchaudhary4253 Рік тому

    Great explanation ❤

  • @anujagrawal60
    @anujagrawal60 2 роки тому +2

    Hi Anuj, this was an excellent explanation. Just a suggestion that you can take the refrence from relative velocity to even simpler. Also you can say that 2*speed_slow = speed_fast for given time resulting the distance equation for same time.
    Also, thank you again for this great explanation. Really appreciate your efforts and hard work

  • @Atul_Agnihotri
    @Atul_Agnihotri Рік тому

    Yes, It was helpful.

  • @furqanahmad5446
    @furqanahmad5446 2 роки тому

    very helpful.. thank u bhaiya

  • @QniqueTales
    @QniqueTales 3 роки тому +1

    it is helpfull bhaiya

  • @gauravjain969
    @gauravjain969 3 роки тому +1

    bhaiya please also cover EDGE CASES , remove loop krne vale program mai aapne edge case cover nahi kra jiske bina code bekaar h

  • @AbhishekKumar-cd4gg
    @AbhishekKumar-cd4gg 3 місяці тому

    nice explanation

  • @helloak7156
    @helloak7156 2 роки тому

    Crystal clear

  • @subhamadhikari
    @subhamadhikari Рік тому

    Thank you brother!

  • @vrindasharma4035
    @vrindasharma4035 2 роки тому

    it was very helpful bhaiyaa!

  • @spiral546
    @spiral546 2 роки тому +1

    yes

  • @workwithmohiit
    @workwithmohiit 9 місяців тому

    Yes it was helpful sir

  • @mcafree1345
    @mcafree1345 Рік тому

    best explainnation

  • @jainikprajapati1632
    @jainikprajapati1632 2 роки тому

    Thank you
    Yes very helpful

  • @MohitJain-g9z
    @MohitJain-g9z Рік тому

    nice explanation.

  • @infinity2arbitrary681
    @infinity2arbitrary681 2 роки тому +2

    It was really very helpful thanks 👍

  • @kapiljetwani3540
    @kapiljetwani3540 2 роки тому

    thank you bhaiya❤❤

  • @VkThummanapally
    @VkThummanapally 2 роки тому

    Yes Very Helpful

  • @onlyPROFIT_BITCOIN
    @onlyPROFIT_BITCOIN 3 роки тому +1

    Yes it was helpful 😇

  • @K.AnshulReddy
    @K.AnshulReddy 4 місяці тому

    lovely proof