Created
November 20, 2020 02:21
-
-
Save GAierken/a418faaa2e3d557a72f989ffc5fd6484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reverseList = (head, previous = null) => { | |
//base case | |
if(!head) return previous | |
//variable to store next node | |
let temp = head.next | |
//reverse the node | |
head.next = previous | |
//recursion starts | |
return reverseList(temp, head) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment