Reverse Sublist in Linked List | (Reverse Linked List II on LeetCode) Explanation

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ส.ค. 2024

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

  • @JyotinderSingh
    @JyotinderSingh  4 ปีที่แล้ว +11

    Count the number of times I said "essentially" in this video :P

  • @staffeng
    @staffeng 3 ปีที่แล้ว +26

    Loved the way you named your variables! Half the battle in understanding is won right there.

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว +3

      Hahaha yes I do like to keep my variable names descriptive! Thank you, and be sure to subscribe for more content!

  • @susmitapatro8720
    @susmitapatro8720 3 ปีที่แล้ว +3

    After spending hours on this problem, i finally understood because of your explanation . Thankyou :)

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad you understood the concept! Be sure to subscribe for more videos!

  • @pythonenthusiast9292
    @pythonenthusiast9292 3 ปีที่แล้ว +4

    hey man , your explanations are so good and voice is quite clear as well. I see you are not making videos currently . I really hope you start it whenever possible cause these are for sure very helpful.
    cheers

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

      Hi! Thanks a lot for the feedback! Yes, I've been taking a break for the last couple of months due to work commitments, but I plan on making new videos very soon! I'm currently exploring different things that I'd like to make more videos on, other than LeetCode :)
      Again, thanks for the support!

  • @yashsaini3331
    @yashsaini3331 2 ปีที่แล้ว +2

    Best Explanation on the internet. Thanks a lot man!

  • @dwivedishashank9
    @dwivedishashank9 3 หลายเดือนก่อน +1

    Thanks man. Will be using variable names going forward :)

  • @engineeringflix
    @engineeringflix 5 หลายเดือนก่อน +3

    very welll explained....

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

    Got stuck on many paid Udemy courses explaining Linked lists, but you definitely nailed it!
    Nice visualization and explanation, also a variable names are incredibly meaningful in understanding this algorithm! Big like!

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

      its showing null pointer exception for this line at 15:58 as nodetobeextracted is null.
      plz help.

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

    Awesome explanation. Though I code in Java, your explanation was the best I could find and understood it properly. thanks

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

      Glad I could help! Be sure to subscribe for more upcoming content! ♥

  • @Ankit.yt_885
    @Ankit.yt_885 2 ปีที่แล้ว +1

    Very Nice Explanation!

  • @saranyavivekanandan9044
    @saranyavivekanandan9044 3 ปีที่แล้ว +3

    Amazing explanation! The best part is the diagram you drew.

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Thank you so much! I'm glad you found this useful, please consider subscribing for more content!

    • @samolusola
      @samolusola 2 ปีที่แล้ว

      @@JyotinderSingh great video. What software do you use to draw and present at the same time?

  • @MayankLC93
    @MayankLC93 2 ปีที่แล้ว +2

    What a crisp explanation.... !!! thank You :)

  • @alkadas4094
    @alkadas4094 3 ปีที่แล้ว +3

    Just loved the variable names...It became damn easy after that to undersatnd

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad you liked it! Be sure to subscribe for more videos!

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

    The simplest solution I found ngl
    Really helpful!

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

      its showing null pointer exception for this line at 15:58 as nodetobeextracted is null.
      plz help.

  • @RituJain-qu6sf
    @RituJain-qu6sf 3 ปีที่แล้ว +2

    Amazingly amazing explanation. Understood in one go :D

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      That's so great go hear! Please consider subscribing for more videos!

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

    your explanation is remarkable, literally I have no words...... superb
    Plzzzzz upload more videos

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

    thank you thank you so much your explanation was the best

  • @adityachauhan1182
    @adityachauhan1182 3 ปีที่แล้ว +2

    Excellent !! Using diagram and name of pointers you have turned this hard concept into soo easy to understand !! Thanks

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      These comments make my day! Please consider subscribing for more content!

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

      I am preparing for my internship will you give some suggestions ?

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Sure, feel free to email /DM me about any specific thing you wish to ask. I'll try my best to help!
      My social media is linked on my profile

    • @adityachauhan1182
      @adityachauhan1182 3 ปีที่แล้ว

      @@JyotinderSingh Can you provide me your LinkedIn account ?

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      www.linkedin.com/in/jyotinder-singh

  • @047gauravkumartiwari5
    @047gauravkumartiwari5 2 ปีที่แล้ว +1

    Very nice explanation.
    Thanks a lot.

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

    This was a great explanation, mate!

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

    Awesome explanation Bhai!!

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

    Thanks for the great insight had trouble understanding this
    In addition we need to add a dummy node (sentinel) to cover for scenarios where we need to reverse from the head of the linkedlist

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

    Wonderful visualization and explanation! Thank you a lot!

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

    Amazing Explanation Brother all there were n doubts at all.

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

    brilliant explanation and naming variables ... thanks a lot

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

      its showing null pointer exception for this line at 15:58 as nodetobeextracted is null.
      plz help.

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

    you are amazing, your code is very explanatory ...

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

    Thanks for the good video

  • @akshitvashishth5481
    @akshitvashishth5481 4 ปีที่แล้ว +3

    Amazing approach! Thanks :)

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

      Glad I could help! Be sure to subscribe for more content!

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

    this is insightful, thanks!

  • @manjotkaur6731
    @manjotkaur6731 3 ปีที่แล้ว +2

    Very good explanation sir

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

      Thank you! Be sure to subscribe for more content!

  • @ishaanshrikantkulkarni4660
    @ishaanshrikantkulkarni4660 3 ปีที่แล้ว

    amaing explaination!!!

  • @Abhishek-ie4mm
    @Abhishek-ie4mm 3 ปีที่แล้ว +1

    Superb explaination.... Thanks man...

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad I could help you understand the concept! Please consider subscribing for more videos!

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

    Thanks for this video, made things a lot easier for me. Great Job!!

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

    big appreciation for this !!

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

    its showing null pointer exception for this line at 15:58 as nodetobeextracted is null.
    plz help.

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

    awesome explanation!

  • @AbhinavKumar-dr4ef
    @AbhinavKumar-dr4ef 2 ปีที่แล้ว

    Krishna bless you. Nice explanation.😊

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

    Great explanation! Only question is, why did we have to create dummy list? Why couldn't we do it with existing list?

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

    Damn! what an explanation !!

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad you were able to understand the concept! Be sure to subscribe for more videos!

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

    Fantastic explanation

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

      Thank you! Please consider subscribing for more videos!

    • @saharshithasa
      @saharshithasa 3 ปีที่แล้ว

      @@JyotinderSingh sure

  • @100_bindusai8
    @100_bindusai8 3 ปีที่แล้ว +2

    Amazing 😊🤩

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว +2

      Thank you! Be sure to subscribe for more content!

  • @hardikmittal4746
    @hardikmittal4746 4 ปีที่แล้ว +2

    if instead of nodeToBeExtracted->next=nodeBeforeSublist->next if we write nodeToBeExtracted->next=workingPtr why is it not working as nodeBeforeSublist->next is pointing to address of workingPtr

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

      WorkingPtr will only be equal to nodeBeforeSublist->next for the first iteration, after that the workingPtr will be further ahead in the list with other elements between itself and nodeBeforeSublist.
      I hope this clears it out, otherwise look at the second iteration in the demo I give in the video, you'll see that there is another element between workingPtr and nodeBeforeSublist once the first element has been 'cut & pasted'.

  • @keshavgaur4535
    @keshavgaur4535 2 ปีที่แล้ว

    Thank you so much

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

    Very helpful. Thanks

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

      Thanks a lot! Be sure to subscribe for more content!

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

    could you please explain the need of dummy pointer and its usecase?

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

      because you can't change directly the main head of the linked list... that's why he has taken the dummy pointer...

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

    Amazing explanation thanks a lot 😊

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad you liked the video! Subscribe for more content!

  • @michaelphan7477
    @michaelphan7477 4 ปีที่แล้ว +3

    Whats the point of the dummy pointer? Still don't understand

    • @michaelphan7477
      @michaelphan7477 4 ปีที่แล้ว +2

      can't you just return head at the end?

    • @JyotinderSingh
      @JyotinderSingh  4 ปีที่แล้ว +3

      Hey, I'm glad you asked. This is a common design pattern while working with linked lists in cases when you need to return a new list.
      The idea is that you always want dummy.next to be the head node. Think of examples when your head might be null, the dummy allows you to keep track of that node. This is also useful in cases when you need to perform some other tasks, such as rotating or reversing a list, when you need a pointer to the previous element of your current node (and your current node might be head itself).
      The point is, you can probably get by without using a dummy node as well, because there's always more than one way to do something. But it's a helpful pattern that you'll realise is adaptable to a lot of problems.
      I hope this helped!

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

      @@JyotinderSingh ahhh ok that makes a lot of sense. thank you. so basically for this probably you don't really need a dummy pointer.

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

      Glad I could help! Be sure to subscribe for more content!

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

      The dummy pointer is used to handle the case where the sublist is at the start of the list

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

    hi, do we always need to have dummy node? I am trying without using dummy but it does not seem to work. Could you please help?

  • @user-sp5uu2ji1i
    @user-sp5uu2ji1i ปีที่แล้ว

    I liked the explanation sir,
    but it will be better to understand if you keep the variable name a little bit shorter (without compromising the meaning)
    Thanks for this awesome content

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

      its showing null pointer exception for this line at 15:58 as nodetobeextracted is null.
      plz help.

  • @muditkumarsingh7627
    @muditkumarsingh7627 3 ปีที่แล้ว +2

    pretty well solution :))

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

      Thank you! Be sure to subscribe for more content!

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

    You are gem bro :) Thanks would be such a small word for ya!

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

      It really means a lot! Thank you!

    • @anikkhan8811
      @anikkhan8811 3 ปีที่แล้ว

      @@JyotinderSingh My pleasure bro 😀

  • @techenthusiast127
    @techenthusiast127 3 ปีที่แล้ว

    Thank you so much!

  • @AvikNayak_
    @AvikNayak_ 3 ปีที่แล้ว

    Can you do a video on Rotate Array,Next Permutation,Product Of array except self ?

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Hey, sure. I'll try adding those :)

  • @ayushvats1808
    @ayushvats1808 3 ปีที่แล้ว

    please someone clear this
    in loop our working pointer needs to be updated na.. with just start++ how our working pointer is getting updated..

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Hey, if you look at the whiteboard explanation, you'll see that we never really update the workingPtr. It always points to the same node (with value 3 in our example). The only thing that changes is the next pointer of the workingPtr, which we do update in every iteration of the loop.
      Hope this clears it up

  • @GauravSharma-wb9se
    @GauravSharma-wb9se 2 ปีที่แล้ว +1

    Whole logic sit at you dummy pointer, I tried this problem with reversing sublist then join likns properly but for 2 elements it got failed, but after seeing your video I got idea of dummy node.

  • @shouryagupta8763
    @shouryagupta8763 3 ปีที่แล้ว

    wow

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

    how on earth am i supposed to come up with this?!