滑动窗口_和为S的连续正数序列
思路:
滑动窗口
# -*- coding:utf-8 -*-
class Solution:
def FindContinuousSequence(self, tsum):
# write code here
low = 1
high = 2
res = []
while low < high:
cursum = sum(range(low, high+1))
if cursum == tsum:
res.append(range(low, high+1))
low += 1
elif cursum < tsum:
high += 1
else:
low += 1
return res