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 16dddfa commit faeaa2bCopy full SHA for faeaa2b
reorder-list/printjin-gmailcom.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def reorderList(self, head):
3
+ if not head:
4
+ return
5
+ nodes = []
6
+ current = head
7
+ while current:
8
+ nodes.append(current)
9
+ current = current.next
10
+ i, j = 0, len(nodes) - 1
11
+ while i < j:
12
+ nodes[i].next = nodes[j]
13
+ i += 1
14
+ if i == j:
15
+ break
16
+ nodes[j].next = nodes[i]
17
+ j -= 1
18
+ nodes[i].next = None
0 commit comments