mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
修复python在md中的语法高亮&代码格式调整
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user