How to reverse a Linked List in JavaScript

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024

Комментарии • 44

  • @TheCodeCreative
    @TheCodeCreative  4 года назад

    To subscribe to the channel: ruclips.net/channel/UCmOpHGj4JRWCdXhllVTZCVw

  • @henryong7788
    @henryong7788 2 года назад +1

    This is one of the most (personally) recommended explanation for Singly Linked List I've found.\
    Very concise and straight to the point with little to no waffling around the topic.

  • @omkadam7336
    @omkadam7336 Год назад +1

    This is the best explanation in reversing the linked list. On GFG there is a same problem to reverse a linked list but test cases are not passing.

  • @nataliafavala4536
    @nataliafavala4536 3 года назад +2

    what if I have to return a new list with the original reversed?

  • @daryaleylian8942
    @daryaleylian8942 2 года назад +1

    Great explanation, thank you for going through each step.

  • @avneet12284
    @avneet12284 3 года назад +1

    Amazing solution. I did it in quadratic time but this is way better.

  • @thecoder2441
    @thecoder2441 2 года назад +1

    Incredible explanation

  • @1oky
    @1oky Год назад +1

    thank u!

  • @JBitzz
    @JBitzz 3 года назад +1

    Thank you for this great explanation

  • @colerau2409
    @colerau2409 3 года назад +1

    Love your explanation and audio quality! One thing, when I tried to code the reverseList function, I needed to pass in "list" and then set "head" to "list.head". Otherwise, my console would tell me "head.next" is undefined.

  • @akinloludavid3
    @akinloludavid3 3 года назад +1

    Awesome video. Very explanatory

  • @roast-salamander
    @roast-salamander Год назад

    Awesome tutorial. There is one thing that I do not understand though. Let's say we have iterated the while loop once and our prev = [5]. When we itereate the loop the second time, prev = [6, 5]. How does 6 stack on top of 5(How does 6 become the head and 5 become the next). I hope my question makes sense, thank you.

  • @AYUSHGUPTA-pi1ib
    @AYUSHGUPTA-pi1ib 3 года назад +1

    Thanks..it was helpful

  • @TheCodeCreative
    @TheCodeCreative  2 года назад

    📖 Download my FREE "Google Search Secrets for Developers" Cheat Sheet:
    store.thecodecreative.com/google-secrets-cheat-sheet

  • @BulletSP
    @BulletSP 3 года назад +1

    thanksa man , beautifully done

  • @zubairzafar480
    @zubairzafar480 2 года назад

    can I get source code? specifically of your ./Node file. I am finding it difficult to implement linked list and reverse it.

  • @TheCodeCreative
    @TheCodeCreative  4 года назад

    🗣JOIN the Code Creative Facebook group! :
    facebook.com/groups/1612600368887577

  • @pratiik37
    @pratiik37 3 года назад +1

    Thanks. Keep doing a good wotk

  • @humancyyborg
    @humancyyborg 3 года назад +1

    Thanks for the video

  • @ajukalive
    @ajukalive 2 года назад +1

    what IDE do you use or extensions if it is vsCode?

    • @TheCodeCreative
      @TheCodeCreative  2 года назад

      Hi David, yes, it's VSCode. I use many extensions. Is there anything in particular you're curious about in the setup?

    • @ajukalive
      @ajukalive 2 года назад +1

      @@TheCodeCreative yes, your javascript syntax highlighter i like how the not equals statement looks

    • @TheCodeCreative
      @TheCodeCreative  2 года назад

      @@ajukalive Ah, ok, those are called ligatures. You want to search for "Fira Code". And you should be able to find out how to install it.

  • @cmdv42
    @cmdv42 2 года назад +1

    🙌💯

  • @hakusaan
    @hakusaan 3 года назад

    You are overriding line 9 with line 11. Line 9 is redundant.

    • @TheCodeCreative
      @TheCodeCreative  3 года назад +3

      Thanks for the comment. Line 11 doesn't override line 9. The purpose of line 9 is to do the reversing, i.e. point the node's "next" property to the previous node. The purpose of lines 10 and 11 are to advance to the next node in the chain. During the next iteration of the loop, we are going to sever the "next" property of that node(which we are now calling "head") and point it to the previous node. Hope that helps!

  • @AkashSingh-ce8xk
    @AkashSingh-ce8xk 2 года назад +1

    You saved my day. 🫀

  • @greggfineguitar
    @greggfineguitar 4 года назад

    🗣JOIN the Code Creative Facebook group! :
    facebook.com/groups/1612600368887577