100 algos in 100 days (Day 29)

paolov1928

Paolo Ventura

Posted on October 18, 2021

100 algos in 100 days (Day 29)

[16/10] A bit of a gap over the last 3 days with some stuff going on.
I started really looking into Linked Lists. Coming from JS we hardly ever use this data structure but in .NET it is quite common so really cool to know more.

Question

Reverse a linked list in place

This was a cool trick to not go all the way through. As long as you keep track of previous, current and next you can do it all there and then.
Something like this pseudo code:

// Copy a pointer to the next element
// before we overwrite currentNode.next
// Reverse the 'next' pointer
// Step forward in the list
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
paolov1928
Paolo Ventura

Posted on October 18, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related