Merge pull request #1686 from jishan7/master

修复python在md中的语法高亮&代码风格优化
This commit is contained in:
程序员Carl
2022-10-15 14:55:51 +08:00
committed by GitHub

View File

@ -181,23 +181,23 @@ class Solution:
index += 1
return 0 if res==float("inf") else res
```
```python3
#滑动窗口
```python
# 滑动窗口
class Solution:
def minSubArrayLen(self, target: int, nums: List[int]) -> int:
if nums is None or len(nums)==0:
if nums is None or len(nums) == 0:
return 0
lenf=len(nums)+1
total=0
i=j=0
while (j<len(nums)):
total=total+nums[j]
j+=1
while (total>=target):
lenf=min(lenf,j-i)
total=total-nums[i]
i+=1
if lenf==len(nums)+1:
lenf = len(nums) + 1
total = 0
i = j = 0
while (j < len(nums)):
total = total + nums[j]
j += 1
while (total >= target):
lenf = min(lenf, j - i)
total = total - nums[i]
i += 1
if lenf == len(nums) + 1:
return 0
else:
return lenf