Skip to content

Instantly share code, notes, and snippets.

@phongngtuan
Last active November 3, 2018 07:53
Show Gist options
  • Select an option

  • Save phongngtuan/6c27b35169699c535513dd90f81fbcda to your computer and use it in GitHub Desktop.

Select an option

Save phongngtuan/6c27b35169699c535513dd90f81fbcda to your computer and use it in GitHub Desktop.
public ListNode reverseList(ListNode head) {
if (head == null) return head;
ListNode curr = head.next;
head.next = null;
while (curr != null) {
ListNode next = curr.next;
curr.next = head;
head = curr;
curr = next;
}
return head;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment