Skip to content

Commit e70a04f

Browse files
committed
7/26 1Q
1 parent abbeb27 commit e70a04f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Definition for singly-linked list.
2+
# class ListNode:
3+
# def __init__(self, val=0, next=None):
4+
# self.val = val
5+
# self.next = next
6+
7+
class Solution:
8+
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
9+
prev, cur = None, head
10+
11+
while cur:
12+
temp = cur
13+
cur = cur.next
14+
temp.next = prev
15+
prev = temp
16+
17+
return prev
18+

0 commit comments

Comments
 (0)