File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -114,11 +114,34 @@ class Solution:
114114
115115```
116116
117- ** _ 复杂度分析 _ **
117+ ** 复杂度分析 **
118118
119119- 时间复杂度:$O(N)$
120120- 空间复杂度:$O(1)$
121121
122+ ## 相关题目
123+
124+ - [ 面试题 02.04. 分割链表] ( https://leetcode-cn.com/problems/partition-list-lcci/ )
125+
126+ 参考代码:
127+
128+ ``` py
129+ class Solution :
130+ def partition (self , head : ListNode, x : int ) -> ListNode:
131+ l1 = cur = head
132+ while cur:
133+ if cur.val < x:
134+ cur.val, l1.val = l1.val, cur.val
135+ l1 = l1.next
136+ cur = cur.next
137+ return head
138+ ```
139+
140+ ** 复杂度分析**
141+
142+ - 时间复杂度:$O(N)$,其中 N 为链表长度。
143+ - 空间复杂度:$O(1)$。
144+
122145大家对此有何看法,欢迎给我留言,我有时间都会一一查看回答。更多算法套路可以访问我的 LeetCode 题解仓库:https://github.com/azl397985856/leetcode 。 目前已经 37K star 啦。
123146大家也可以关注我的公众号《力扣加加》带你啃下算法这块硬骨头。
124147![ ] ( https://tva1.sinaimg.cn/large/007S8ZIlly1gfcuzagjalj30p00dwabs.jpg )
You can’t perform that action at this time.
0 commit comments