Skip to content

Instantly share code, notes, and snippets.

@GAierken
Created November 20, 2020 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GAierken/a418faaa2e3d557a72f989ffc5fd6484 to your computer and use it in GitHub Desktop.
Save GAierken/a418faaa2e3d557a72f989ffc5fd6484 to your computer and use it in GitHub Desktop.
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