_ Sliding window and the number of consecutive positive sequence S
Ideas: sliding window
Reprinted from:
https://blog.csdn.net/gui951753/article/details/92416352
# -*- coding:utf-8 -*-
class Solution:
def FindContinuousSequence(self, tsum):
# write code here
if tsum < 3:
return []
results = []
p_low = 1
p_high = 2
while p_low < p_high:
if sum(range(p_low,p_high+1))==tsum:
results.append((range(p_low,p_high+1)))
p_high += 1
elif sum(range(p_low,p_high+1))<tsum:
p_high += 1
else:
p_low += 1
return results