LeetCode--双指针
1.python
class Solution(object):
def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
# 使用两个指针分别指向数组头和尾,最差的结果是把数组都遍历一遍,时间复杂度为O(N),引入了两个额外变量,空间复杂度为O(1)
.
原创
2020-10-27 10:55:32 ·
178 阅读 ·
1 评论