Skip to content

Instantly share code, notes, and snippets.

@youngjinmo
Created January 31, 2023 05:02
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 youngjinmo/466f37ffa6eabd9141e1a937c6d6bb04 to your computer and use it in GitHub Desktop.
Save youngjinmo/466f37ffa6eabd9141e1a937c6d6bb04 to your computer and use it in GitHub Desktop.
public class Solution {
public ListNode reverseList(ListNode head) {
ListNode prev = null;
ListNode current = head;
while (current != null) {
ListNode next = current.next;
current.next = prev;
prev = current;
current = next;
}
return prev;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment