Created
January 31, 2023 05:02
-
-
Save youngjinmo/466f37ffa6eabd9141e1a937c6d6bb04 to your computer and use it in GitHub Desktop.
Leetcode 206 : https://leetcode.com/problems/reverse-linked-list/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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