Skip to content

Commit 3cb2592

Browse files
committed
Simplify while loop condition in reverseList
1 parent 261ab90 commit 3cb2592

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

reverse-linked-list/KwonNayeon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
3939
prev = None
4040
curr = head
4141

42-
while curr is not None:
42+
# 마지막 노드도 처리해야 함
43+
while curr:
4344

4445
temp = curr.next
4546
curr.next = prev

0 commit comments

Comments
 (0)