Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f2a8792

Browse files
authored
Create Day-7_Reverse_a_SLL.py
1 parent 5409ce4 commit f2a8792

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]:
3+
prev = None
4+
while head:
5+
x = head.next
6+
head.next = prev
7+
prev = head
8+
head = x
9+
10+
return prev

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /