Skip to content

Commit 72e4cd7

Browse files
author
Yi Gu
committed
[LinkedList] fix variable style of Partition List
1 parent 2281323 commit 72e4cd7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

LinkedList/PartitionList.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,26 @@
1919
class PartitionList {
2020
func partition(head: ListNode?, _ x: Int) -> ListNode? {
2121
let prevDummy = ListNode(0)
22-
var prev: ListNode? = prevDummy
22+
var prev = prevDummy
2323
let postDummy = ListNode(0)
24-
var post: ListNode? = postDummy
24+
var post = postDummy
2525

2626
var node = head
2727

2828
while node != nil {
2929
if node!.val < x {
30-
prev!.next = node
31-
prev = prev!.next
30+
prev.next = node
31+
prev = node!
3232
} else {
33-
post!.next = node
34-
post = post!.next
33+
post.next = node
34+
post = node!
3535
}
3636

3737
node = node!.next
3838
}
3939

40-
post!.next = nil
41-
prev!.next = postDummy.next
40+
post.next = nil
41+
prev.next = postDummy.next
4242

4343
return prevDummy.next
4444
}

0 commit comments

Comments
 (0)