end = silde start = 0 while end<len(nums): new_max_sum = sum(nums[start:end]) if new_max_sum>=max_sum: returnTrue
start += 1 end+=1
returnFalse
if k>n: print(n) else: max_len = 0 i =0 tmp_len = 0 while i<n: if nums[i]==1: tmp_len +=1 else: tmp_len = 0
max_len = max(max_len,tmp_len) i+=1
if max_len+k>=n: print(n) else: flag = True silde = max_len + k max_sum = max_len while flag: if get_maxsum(silde,nums,max_sum): silde += 1 max_sum+=1 else: flag = False print(silde-1)