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 52805fa commit 1f2cb01Copy full SHA for 1f2cb01
reverse-linked-list/printjin-gmailcom.py
@@ -0,0 +1,16 @@
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):
9
+ prev = None
10
+ current = head
11
+ while current:
12
+ nxt = current.next
13
+ current.next = prev
14
+ prev = current
15
+ current = nxt
16
+ return prev
0 commit comments