We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent da4df4f commit 9a4fe5eCopy full SHA for 9a4fe5e
reverse-linked-list/kayden.java
@@ -12,13 +12,13 @@
12
// 공간복잡도: O(1)
13
class Solution {
14
public ListNode reverseList(ListNode head) {
15
-
16
ListNode prev = null;
17
18
while (head != null){
19
- ListNode curr = new ListNode(head.val, prev);
20
- prev = curr;
21
- head = head.next;
+ ListNode next = head.next;
+ head.next = prev;
+ prev = head;
+ head = next;
22
}
23
24
return prev;
0 commit comments