Skip to content

Instantly share code, notes, and snippets.

@MorrisLaw
Created June 3, 2022 10:29
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 MorrisLaw/ee3d8aae234bdd2c0ac97e0072865e00 to your computer and use it in GitHub Desktop.
Save MorrisLaw/ee3d8aae234bdd2c0ac97e0072865e00 to your computer and use it in GitHub Desktop.
Reverse Linked List - LeetCode 206
func reverseList(head *ListNode) *ListNode {
curr := head
var prev *ListNode
for curr != nil {
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