Skip to content

Commit 559a27b

Browse files
committed
refactor: 7주차 리뷰 반영 - 2
1 parent 3cd4cc7 commit 559a27b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

reverse-linked-list/Chaedie.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
22
Solution:
3-
1) next node를 저장합니다.
3+
1) temp node를 저장합니다.
44
2) cur node 를 prev node 로 연결시킵니다.
55
3) cur node 가 prev node 가 됩니다.
6-
4) cur node 는 next node 가 됩니다.
6+
4) cur node 는 temp node 가 됩니다.
77
Time: O(n)
88
Space: O(1)
99
"""
@@ -14,8 +14,8 @@ def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
1414
prev = None
1515
cur = head
1616
while cur:
17-
next = cur.next
17+
temp = cur.next
1818
cur.next = prev
1919
prev = cur
20-
cur = next
20+
cur = temp
2121
return prev

0 commit comments

Comments
 (0)