LeetCode 206: Reverse Linked List RECURSIVELY - Interview Prep Ep 60

Опубликовано: 15 Май 2026
на канале: Fisher Coder
15,320
511

⭐ Shop on Amazon to support me: https://www.amazon.com/?tag=fishercod...
⭐ NordVPN to protect your online privacy: https://go.nordvpn.net/aff_c?offer_id...
⭐ NordPass to help manage all of your passwords: https://go.nordpass.io/aff_c?offer_id...

Here's the ITERATIVE solution:    • LeetCode 206: Reverse Linked List ITERATIV...  

⭐ Support my channel and connect with me:
   / @fishercoder  

LeetCode 206. Reverse Linked List

Reverse a singly linked list.

Example:
Input: [1,2,3,4,5]
Output: [5,4,3,2,1]

Follow up:
A linked list can be reversed either iteratively or recursively. Could you implement both?

Problem link: https://leetcode.com/problems/reverse...

Solutions explained (Recursive approach):
1. We'll write a helper function to help us do the recursion which takes the given head node and a newHead node (start with null);
2. Base condition: when head == null, we'll just return newHead;
3. If all other cases, we'll do the four-step process to keep assigning head.next pointer to point to newHead, and then move both head and newHead towards the right by using the recursive function until we reach the end of the given linked list.
4. return newHead;

Time: O(n)
Space: O(n)

// TOOLS THAT I USE:
○ Memory Foam Set Keyboard Wrist Rest Pad - https://amzn.to/3cOGOAj
○ Electric Height Adjustable Standing Desk - https://amzn.to/2S9YexJ
○ Apple Magic Keyboard (Wireless, Rechargable) - https://amzn.to/36gy5FJ
○ Apple Magic Trackpad 2 (Wireless, Rechargable) - https://amzn.to/36ltimu
○ Apple MacBook Pro - https://amzn.to/30iSvKE
○ All-In One Printer - https://amzn.to/34etmSi
○ Apple AirPods Pro - https://amzn.to/2GpVYQf
○ My new favorite Apple Watch - https://amzn.to/2EIIUFd

// MY FAVORITE BOOKS:
○ Introduction to Algorithms - https://amzn.to/36hxHXD
○ Designing Data-Intensive Applications - https://amzn.to/2S7snOg
○ Head First Java - https://amzn.to/2ScLDKa
○ Design Patterns - https://amzn.to/2SaGeU2


Follow me on Github for complete LeetCode solutions: https://github.com/fishercoder1534/Le...

Support me on Patreon:   / fishercoder  

My ENTIRE Programming Equipment and Computer Science Bookshelf:
https://www.amazon.com/shop/fishercoder

And make sure you subscribe to my channel!

Your comments/thoughts/questions/advice will be greatly appreciated!

#softwareengineering #leetcode #algorithms #coding #interview #SDE #SWE #SiliconValley #programming #datastructures