这次选取的题是leetcode的array下209. Minimum Size Subarray Sum(原题链接)
题目如下:
源代码:
class Solution(object):
#()
def minSubArrayLen(self, s, nums):
start = 0
sum = 0
min_size = float("inf")
for i in range(0, len(nums)):
sum += nums[i]
while sum >= s:
min_size = min(min_size, i-start+1)
sum -= nums[start]
start += 1
if min_size != float("inf"):
return min_size
else:
return 0
"""
:type s: int
:type nums: List[int]
:rtype: int
"""
通过后截图: