Skip to content

Commit 730cca2

Browse files
committed
Runtime: 53 ms (Top 53.47%) | Memory: 13.8 MB (Top 76.51%)
1 parent 60a0e9f commit 730cca2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
# Runtime: 53 ms (Top 53.47%) | Memory: 13.8 MB (Top 76.51%)
12
# Definition for singly-linked list.
23
# class ListNode(object):
3-
# def __init__(self, val=0, next=None):
4-
# self.val = val
5-
# self.next = next
4+
# def __init__(self, val=0, next=None):
5+
# self.val = val
6+
# self.next = next
67
class Solution(object):
78
def partition(self, head, x):
89
"""
@@ -12,21 +13,21 @@ def partition(self, head, x):
1213
"""
1314
lessthan = []
1415
greateql = []
15-
16+
1617
while head:
1718
if head.val < x:
1819
lessthan.append(head.val)
1920
else:
2021
greateql.append(head.val)
2122
head = head.next
22-
23+
2324
h = res = ListNode()
24-
25+
2526
for i in range(len(lessthan)):
2627
res.next = ListNode(lessthan[i])
2728
res = res.next
2829
for i in range(len(greateql)):
2930
res.next = ListNode(greateql[i])
3031
res = res.next
31-
32-
return h.next
32+
33+
return h.next

0 commit comments

Comments
 (0)