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