L9. Reverse a LinkedList | Iterative and Recursive

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ก.พ. 2025
  • Problem Link: tinyurl.com/2a...
    Entire LL Sheet: takeuforward.o...
    Check our A2Z DSA Course: takeuforward.o...
    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/take...

ความคิดเห็น • 197

  • @pratulyapratap9329
    @pratulyapratap9329 ปีที่แล้ว +116

    U r not only teaching linkedlist u r teaching values to give back to this community..
    Thankyou Striver

  • @tanisha999-e2w
    @tanisha999-e2w ปีที่แล้ว +36

    Hands down, the best explanation on TH-cam!

  • @_SahilShah
    @_SahilShah 6 หลายเดือนก่อน +31

    00:10 Iterative Approach
    14:39 Recursive Approach
    very nice explanation Striver!
    Understood!

  • @samreenimam8608
    @samreenimam8608 9 หลายเดือนก่อน +43

    I was confused until I watched the dry run of recursion... Thanks for having Striver!..

  • @abid3801
    @abid3801 ปีที่แล้ว +13

    Awesome man. The way you tried to portray the recursive one is actually over the moon..

    • @monikarawat5125
      @monikarawat5125 2 หลายเดือนก่อน

      Right actually over the moon 🌝 sir 🙏🏻🙏🏻taught us the beauty of recursion beautifully and factually ❤😇

  • @aryanpinto5105
    @aryanpinto5105 ปีที่แล้ว +15

    Was a bit confused regarding recursive approach of this problem for a while. Your explanation just cleared out all of it. Great video!!❤💯

  • @1handclaps
    @1handclaps 10 หลายเดือนก่อน +4

    If you are a beginner or even an intermediate this is the best playlist to follow for DSA

  • @durgeshjadhav01
    @durgeshjadhav01 10 หลายเดือนก่อน +6

    Logic are crystal clear with your perfection in explanation , i don't even
    need to look code .

  • @AmanSharma-xy1qm
    @AmanSharma-xy1qm ปีที่แล้ว +7

    All the video lectures and the articles helped me a lot to gain confidence in DSA and will be helping me in the interviews. Thank you Striver bhaiya for bringing such amazing content for free.

  • @pranavdharkar
    @pranavdharkar 10 วันที่ผ่านมา +2

    recursive approach is explained crystal clear in the documentation article

  • @hardikkumarsingh
    @hardikkumarsingh ปีที่แล้ว +5

    Exceptional explanation !!! I've never intuitively understood recursive version of reversing a LinkedList, but this video helped me understand that too so easily🙇🙇

  • @sanchitsanyam7359
    @sanchitsanyam7359 9 หลายเดือนก่อน +10

    recursive approach of soving linked list is awesome non of any youtuber has explained it such fantastically

  • @NidhiKumari-vu3oj
    @NidhiKumari-vu3oj 24 วันที่ผ่านมา +1

    I am amazed by the recursive solution and loved the dry run...thank you so much!!!! :)

  • @gauravmishra8782
    @gauravmishra8782 ปีที่แล้ว +12

    The dry run part is genius!! very nice explanation.

  • @surayahappy120
    @surayahappy120 ปีที่แล้ว +72

    so beautiful so elegant just looking like a wow

  • @raghavgarg-oo6mx
    @raghavgarg-oo6mx 11 หลายเดือนก่อน +2

    explanation of the recursive approach was just exceptional .
    thankyouu striver

  • @ritikshandilya7075
    @ritikshandilya7075 9 หลายเดือนก่อน +2

    Recursion approach is just LIT , bhai kamal kr diya striver bhai

  • @MrRon-jx9vx
    @MrRon-jx9vx 9 หลายเดือนก่อน +1

    Great explanation!!! The best i've ever seen on recursion !

  • @AADITYASINGH-b2z
    @AADITYASINGH-b2z 4 หลายเดือนก่อน +1

    Kudos from the entire community for such beautiful explanation.

  • @Salman_Patel_07
    @Salman_Patel_07 5 หลายเดือนก่อน

    Crystal clear !!! Thanks for explaining the recursion topic soo beautifully and making it easier to understand. ❤

  • @surge3.14
    @surge3.14 8 หลายเดือนก่อน

    Your DryRun thing in these recursion approaches is amazing

  • @ddevarapaga5134
    @ddevarapaga5134 6 หลายเดือนก่อน

    Brooo u are crazyyyy that dry run is the best i have seen thank you understood

  • @harshilpatel3205
    @harshilpatel3205 11 หลายเดือนก่อน +1

    Amazing explanation at recursive approach thank you striver for this amazing course😊🎉

  • @endlesslearning26
    @endlesslearning26 5 หลายเดือนก่อน

    The recursion code is always a delight to understand , coz you think that how could be solved soo elegantly

  • @dhruvsovasaria
    @dhruvsovasaria 3 หลายเดือนก่อน

    thankyou , tried to understand the recursive approach from everywhere before this since last night , finally understood

  • @darshitsingh4378
    @darshitsingh4378 4 หลายเดือนก่อน +1

    BEST VIDEO ON TH-cam SEEN ALL

  • @PCCOERCoder
    @PCCOERCoder 2 หลายเดือนก่อน +2

    Lecture successfully completed on 27/11/2024 🔥🔥

    • @nithins6273
      @nithins6273 2 หลายเดือนก่อน

      did u complete whole linked list playlist?

  • @manasbhatia1191
    @manasbhatia1191 7 หลายเดือนก่อน +25

    Is it me or anyone else also thinks that things have been a little tougher from Linked List

    • @vibhavsharma2724
      @vibhavsharma2724 7 หลายเดือนก่อน +7

      I think it's you only.

    • @aspirant500days7
      @aspirant500days7 7 หลายเดือนก่อน +5

      No man. I've given up on Linked last multiple times to reach this far (not even half).

    • @vedikamishra009
      @vedikamishra009 2 หลายเดือนก่อน

      @@vibhavsharma2724 🙂

    • @saitamathecoder1386
      @saitamathecoder1386 15 วันที่ผ่านมา +1

      Just you buddy

  • @adveshdarvekar7733
    @adveshdarvekar7733 4 หลายเดือนก่อน +1

    Thank you for putting so much hardwork!

  • @ujjwalsingh6889
    @ujjwalsingh6889 10 หลายเดือนก่อน

    Finally I understood this recursive concept.........Nice Explanation👍👍

  • @adityamukherjee2207
    @adityamukherjee2207 2 หลายเดือนก่อน

    bhaiyya thank u so much for this explanation tomorrow i have ds end sem exam and still this video helped me a lot . thank u so much.

  • @Ammmmmmmman
    @Ammmmmmmman ปีที่แล้ว +1

    Dry run part was actually brilliant

  • @Rieshu-l9i
    @Rieshu-l9i 11 หลายเดือนก่อน

    Amazingly explained, #Striver rocks, gold bless you & all

  • @honeyjot8709
    @honeyjot8709 11 หลายเดือนก่อน

    Loved the explanation for recursive solution, especially the DRY RUN

  • @_thingsthatmatter
    @_thingsthatmatter 7 หลายเดือนก่อน

    i love youuuu u r thee besttttt teacherrrrrrrr EVERRRRRRRRRRRRR

  • @hiteshsharma9192
    @hiteshsharma9192 ปีที่แล้ว

    Broo your way of explaining is awesom👍👍

  • @FifthArima
    @FifthArima 8 หลายเดือนก่อน +6

    The way he explains sounds like Arnab Goswami highlighting the news ! 😂

  • @amitarya4894
    @amitarya4894 6 หลายเดือนก่อน

    Awesome and hats off 🙏🙏
    thank you so much Striver.

  • @adharapuramnavaneeth9925
    @adharapuramnavaneeth9925 ปีที่แล้ว +1

    greatest video superb sir !!

  • @swagatrout3075
    @swagatrout3075 ปีที่แล้ว

    thank you man tanks for clarifying the recursion from scratch

  • @bhusanrath9698
    @bhusanrath9698 8 หลายเดือนก่อน

    0:00 -4:58 = Brute Force (Using Stack)
    5:00 - 14:45 = Iterative
    14:50 = Recursive

  • @stith_pragya
    @stith_pragya ปีที่แล้ว

    UNDERSTOOD, Thank You So Much for this wonderful video...........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • @cjonyoutube3011
    @cjonyoutube3011 2 หลายเดือนก่อน

    Beautifully explained

  • @ankitghanshala7382
    @ankitghanshala7382 หลายเดือนก่อน

    head->next in recursive call is the head for base condition..so the function returns last node after head->next recursive call for the second last node is called.

  • @swathigp3818
    @swathigp3818 7 หลายเดือนก่อน

    I was very confused with this recursive method, how does it reverse. It is super clear after watching your video !

  • @arhamansari1312
    @arhamansari1312 3 หลายเดือนก่อน

    Excellent work. Thank you so much!!!

  • @kalpking...4496
    @kalpking...4496 11 หลายเดือนก่อน +1

    understood very much
    thank you sir

  • @dharmeshkumarkhairnar6583
    @dharmeshkumarkhairnar6583 12 วันที่ผ่านมา

    Good Approach!

  • @lakshayverma6557
    @lakshayverma6557 7 หลายเดือนก่อน

    dry run was awesome

  • @adebisisheriff159
    @adebisisheriff159 ปีที่แล้ว

    Simply the best!!!

  • @mohitparmar01
    @mohitparmar01 6 หลายเดือนก่อน

    best explanation ever!

  • @PratibhaSharma-h7b
    @PratibhaSharma-h7b 17 วันที่ผ่านมา

    Thanks a ton Striver
    .

  • @girirajsingh4467
    @girirajsingh4467 7 หลายเดือนก่อน +1

    you are a genius

  • @prathambhatia3040
    @prathambhatia3040 6 หลายเดือนก่อน

    Thanks for that dry run approach

  • @HemangSinghal-op5ep
    @HemangSinghal-op5ep 6 หลายเดือนก่อน

    Awesome Explanation!

  • @rahuldwivedi4758
    @rahuldwivedi4758 ปีที่แล้ว

    Even more concise:
    function reverseList(head, prev=null){
    if(head === null) return prev;
    const next = head.next;
    head.next = prev;
    return reverseList(head.next, head);
    }

  • @highfiveseries2244
    @highfiveseries2244 หลายเดือนก่อน +2

    12/22/2024 _Good Explanation Striver bhaiya ❤

  • @saitehith6647
    @saitehith6647 10 หลายเดือนก่อน

    Just Brilliant ❤

  • @kumarnishantnitallahabad160
    @kumarnishantnitallahabad160 8 หลายเดือนก่อน

    Wow great explanation

  • @prad2003
    @prad2003 8 หลายเดือนก่อน

    best explanation ever

  • @AvijitGhosh-o1r
    @AvijitGhosh-o1r 5 หลายเดือนก่อน

    Very well explained. Thanks

  • @AbhishekKumar-cd4gg
    @AbhishekKumar-cd4gg 7 หลายเดือนก่อน

    understood , best part was dry run of recursive code

  • @prathamesh009m
    @prathamesh009m ปีที่แล้ว

    Awesome teaching

  • @ojasviagrawal3180
    @ojasviagrawal3180 ปีที่แล้ว

    excellent explanation was just fabbb

  • @KrishnaKumar-b4m9p
    @KrishnaKumar-b4m9p 2 วันที่ผ่านมา

    in the recursive code instead of assigning head->next as front everytime and then operating on front to point it to head we can do a simple more approach with just 2 lines. we can directly tell head's next pointer to point towards head and at last tell head to point towards null. easy peasy just 2 line code. Here is the code-
    ListNode* reverse(ListNode* head){
    if(head==nullptr || head->next==nullptr){
    return head;
    }
    ListNode* newhead= reverse(head->next);



    head->next->next = head; // Point the next node's next to the current node
    head->next = nullptr;


    return newhead;

    }

    • @KrishnaKumar-b4m9p
      @KrishnaKumar-b4m9p 2 วันที่ผ่านมา

      will anyone tell me whats the benefit of learning recursive solution if its time complexity is still same as the simple method in which we were changing the links?

  • @AshwaniKumar-ew1cn
    @AshwaniKumar-ew1cn 2 หลายเดือนก่อน

    Superb!

  • @dhanushkiran-k3j
    @dhanushkiran-k3j ปีที่แล้ว

    Best video explanation

  • @knowthrvdo
    @knowthrvdo 11 หลายเดือนก่อน

    NICE LECTURE AND PLZ UPLOAD REMAINING LECTURES OF A TO Z SDA SHEET PLZ THEY ARE VERY HELPFULL FOR US

  • @rishu4800
    @rishu4800 ปีที่แล้ว

    Amazing explanation

  • @codeman3828
    @codeman3828 ปีที่แล้ว

    Great video

  • @shwetachoudhary9003
    @shwetachoudhary9003 2 หลายเดือนก่อน

    got it soo well❤

  • @PeterParker-ee6ep
    @PeterParker-ee6ep 5 หลายเดือนก่อน

    dry run makes the explanation clear.

  • @__.redcode._
    @__.redcode._ 2 หลายเดือนก่อน +1

    t1 = head; // Initialize t1 to point to the head
    t3 = NULL; // Initialize t3 as NULL (previous pointer)
    t4 = t1->next; // Initialize t4 to the second node in the list
    t2 = NULL; // Initialize t2 as NULL
    int c = 1; // Start with c = 1
    while (t4 != NULL) {
    if (c == 1) {
    c--; // Decrement c
    t2 = t1; // Set t2 to point to t1
    t4 = t2->next; // Move t4 to the next node
    t1->next = t3; // Reverse the link for t1
    t3 = t2; // Move t3 forward to t2
    } else {
    c++; // Increment c
    t3 = t4->next; // Store the next node of t4 in t3
    t1 = t4; // Move t1 forward to t4
    t4->next = t2; // Reverse the link for t4
    t2 = t1; // Move t2 forward to t1
    t4 = t3; // Move t4 forward to the next node
    }
    }
    head = t1; // Update head to the new first node after reversal
    this might be a complex alternative , was for me when i deduced for the first time ;) and little bit of confusion removal by GPT my friend in need
    using swapping the pointers and accessing their respected node's next for reversing the linked list

  • @sibiranganath
    @sibiranganath 9 หลายเดือนก่อน

    Recursive approach: 14:50

  • @pankajsunal9819
    @pankajsunal9819 11 หลายเดือนก่อน

    thanks for this explanation

  • @SomalinBagarty
    @SomalinBagarty 8 หลายเดือนก่อน

    Amazing !!!

  • @banothutharun2743
    @banothutharun2743 11 หลายเดือนก่อน

    what a man 👏👏

  • @nuraynasirzade
    @nuraynasirzade 9 หลายเดือนก่อน +1

    Striver i'm solving A2Z course and i'm at the strings but there is no video explanation for them. i searched videos on youtube but one explains in detail and clear like you. So can you PLEASE make videos on that topic(i will wait). Thank You

  • @YourCodeVerse
    @YourCodeVerse ปีที่แล้ว

    Understood✅🔥🔥

  • @deepakff7498
    @deepakff7498 14 วันที่ผ่านมา

    bhaya u r the best

  • @gauravbanerjee2898
    @gauravbanerjee2898 ปีที่แล้ว

    Understood Thanks a lot ❣❣

  • @pavanKumar-hm7on
    @pavanKumar-hm7on ปีที่แล้ว

    you are our god . thank you soo much

  • @aavashkuikel1341
    @aavashkuikel1341 9 หลายเดือนก่อน

    15:00 Recursion Starts

  • @ABISHEK-r7k
    @ABISHEK-r7k ปีที่แล้ว

    UNDERSTOOD SIR

  • @s.saranya2486
    @s.saranya2486 ปีที่แล้ว

    the BEST💯

  • @shouryadubey2878
    @shouryadubey2878 14 วันที่ผ่านมา

    watched 2 times then i understood code flow completely

  • @ManasNandMohan
    @ManasNandMohan ปีที่แล้ว +1

    So Beautiful , So elegant just looking like a WoW

  • @RamkumarB-k5r
    @RamkumarB-k5r 2 วันที่ผ่านมา

    I understood bro...

  • @ankithazra2005
    @ankithazra2005 7 หลายเดือนก่อน +2

    you are god

  • @diptamoy12
    @diptamoy12 ปีที่แล้ว

    bhaiyaa app great ho❤❤❤❤

  • @RohanWaniMIT
    @RohanWaniMIT 21 วันที่ผ่านมา

    Love you striver

  • @ArpanChakraborty-do6yz
    @ArpanChakraborty-do6yz 11 หลายเดือนก่อน

    Understand ❤❤

  • @snehashisratna9074
    @snehashisratna9074 ปีที่แล้ว

    big fan bhai luv you bhai

  • @manga_mania.
    @manga_mania. ปีที่แล้ว

    Thank you striver😃😃

  • @khalasianiket816
    @khalasianiket816 7 หลายเดือนก่อน

    understood ❤

  • @hashcodez757
    @hashcodez757 7 หลายเดือนก่อน

    9:45 Take U Forward

  • @rockstarCoolz
    @rockstarCoolz 8 หลายเดือนก่อน

    Thanks 🙏 sir

  • @annapureddyravi4054
    @annapureddyravi4054 8 หลายเดือนก่อน

    Bro can you push the code ..The way you explain is very interesting to watch and learn the concepts.

  • @mainakdasgupta7130
    @mainakdasgupta7130 28 วันที่ผ่านมา

    thank you man

  • @Learnprogramming-q7f
    @Learnprogramming-q7f 11 หลายเดือนก่อน

    Thank you bhaiya