Skip to content

Instantly share code, notes, and snippets.

@pjcodesjs
Created March 12, 2023 04:49
Show Gist options
  • Save pjcodesjs/4f83fe1b21b5d2d151b4f4a9540e9bf0 to your computer and use it in GitHub Desktop.
Save pjcodesjs/4f83fe1b21b5d2d151b4f4a9540e9bf0 to your computer and use it in GitHub Desktop.
function reverseLinkedList(head) {
let prev = null;
let curr = head;
while (curr !== null) {
let next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
return prev;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment