File tree Expand file tree Collapse file tree 1 file changed +0
-33
lines changed Expand file tree Collapse file tree 1 file changed +0
-33
lines changed Original file line number Diff line number Diff line change @@ -170,39 +170,6 @@ public:
170
170
171
171
如果[ 两数之和] ( https://mp.weixin.qq.com/s/uVAtjOHSeqymV8FeQbliJQ ) 要求返回的是数值的话,就可以使用双指针法了。
172
172
173
- > 更过算法干货文章持续更新,可以微信搜索「代码随想录」第一时间围观,关注后,回复「Java」「C++」 「python」「简历模板」「数据结构与算法」等等,就可以获得我多年整理的学习资料。
174
-
175
-
176
-
177
- ## tmp
178
-
179
- ```python
180
- class Solution :
181
- def threeSum(self, nums: List[ int] ) -> List[ List[ int]] :
182
- res = [ ]
183
- nums.sort()
184
- for i in range(len(nums)):
185
- if nums[ i] > 0 :
186
- return res
187
- if nums[ i] == nums[ i-1] and i>0:
188
- continue
189
- left = i + 1
190
- right = len(nums) - 1
191
- while left < right:
192
- if nums[ i] + nums[ left] + nums[ right] > 0:
193
- right -= 1
194
- elif nums[ i] + nums[ left] + nums[ right] < 0:
195
- left += 1
196
- else:
197
- res.append([ nums[ i] , nums[ left] , nums[ right]] )
198
- while left < right and nums[ right] == nums[ right-1] :
199
- right -= 1
200
- while left < right and nums[ left] == nums[ left+1] :
201
- left += 1
202
- left += 1
203
- right -= 1
204
- return res
205
- ```
206
173
207
174
208
175
You can’t perform that action at this time.
0 commit comments