题目描述:
代码:
class Solution(object):
def findContinuousSequence(self, target):
#采用滑动窗口法来取数组
head=1 #滑动窗口头
tail=0 #滑动窗口尾
sum=0
result=[]
while head < (target//2)+1 :
if sum < target: #总数不足,扩尾
tail+=1
sum+=tail
elif sum > target : #总数超限,缩头
sum -= head
head += 1
else:
result.append(list(range(head,tail+1)))
sum -= head
head+=1
return result