HackerRank - Reverse Linked List | Full solution with visuals | Study Algorithms

preview_player
Показать описание
A very popular and famous interview question. In this problem you are given a single Linked List which needs to be reversed such that the last element becomes the first element of the list. You can have several ways to approach this problem. One way could be to create an entirely new list in a reversed order or we can take advantage of the node addresses to manipulate. This video shows you animations which will help you to understand the concept behind it. Along with it, we also write the code.

Chapters:
00:00 - Intro
01:11 - Problem statement and description
02:01 - Method 1: Creating a new reversed list (using stacks)
03:59 - Code using stacks
06:59 - Method 2: Efficient solution by manipulating next nodes
08:41 - Dry-run of Code
13:25 - Final Thoughts

📚 Links to topics I talk about in the video:

📘 A text based explanation is available at:

📖 Reference Books:

🎥 My Recording Gear:

💻 Get Social 💻

#hackerrank #programming #interview
Рекомендации по теме
Комментарии
Автор

No doubt you're an excellent teacher! ❤

technicalguy.
Автор

At the end u can just return prevNode without doing head = prevNode... btw nice tutorials 😃

Sranju
Автор

Really like your explanation!! I’m new to programming, you make it really easy for beginners to understand. 👍👍👍

syw
Автор

Thank you for your wonderful explanation

pavanshanmukh
Автор

thanks a lot ! This was easy to understand.I took a udemy course on dsa But they don't teach with diagrams like you do. Please if you any paid subscription let me know i would buy for sure. Also if possible can u suggest some good resources(books or courses) which are more diagram oriented rather than just running a code .

reactninja
Автор

I'm stuck in last iteration you skipped that part please explain 12:09

picyxsz
Автор

why do you have to initialize the reversedList with Integer.MIN_VALUE? the value we assign does not matter since we are returning reversedList.next at the end anyway?

johncho
Автор

currNode.next = preNode; ----> Is this statement only assign preNode's value to currNode's next node which is 8. and If this statement is assigning values then how ListNode nextNode = currNode.next; ---> this statement giving us next node. Confusing!

MaulikDodiaHollywoodMovieLover