mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2025-08-16 10:52:54 +00:00
代码重构 【Github Actions】
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
> 如果阅读时,发现错误,或者动画不可以显示的问题可以添加我微信好友 **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
|
||||
> 如果阅读时,发现错误,或者动画不可以显示的问题可以添加我微信好友 **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
|
||||
>
|
||||
> 感谢支持,该仓库会一直维护,希望对各位有一丢丢帮助。
|
||||
>
|
||||
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
|
||||
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
|
||||
|
||||
#### [209. 长度最小的子数组](https://leetcode-cn.com/problems/minimum-size-subarray-sum/)
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
|
||||
示例:
|
||||
|
||||
> 输入:s = 7, nums = [2,3,1,2,4,3]
|
||||
> 输入:s = 7, nums = [2,3,1,2,4,3]
|
||||
> 输出:2
|
||||
> 解释:子数组 [4,3] 是该条件下的长度最小的子数组。
|
||||
|
||||
|
||||
|
||||
#### 题目解析
|
||||
|
||||
滑动窗口:**就是通过不断调节子数组的起始位置和终止位置,进而得到我们想要的结果**,滑动窗口也是双指针的一种。
|
||||
@@ -28,14 +26,10 @@
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
好啦,该题的解题思路我们已经了解啦,下面我们看一下,代码的运行过程吧。
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
#### 题目代码
|
||||
|
||||
Java Code:
|
||||
@@ -55,7 +49,7 @@ class Solution {
|
||||
sum -= nums[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return windowlen == Integer.MAX_VALUE ? 0 : windowlen;
|
||||
|
||||
}
|
||||
@@ -84,7 +78,7 @@ public:
|
||||
|
||||
Python3 Code:
|
||||
|
||||
```python
|
||||
```python
|
||||
from typing import List
|
||||
import sys
|
||||
class Solution:
|
||||
@@ -99,7 +93,7 @@ class Solution:
|
||||
windowlen = min(windowlen, j - i + 1)
|
||||
sum -= nums[i]
|
||||
i += 1
|
||||
|
||||
|
||||
if windowlen == sys.maxsize:
|
||||
return 0
|
||||
else:
|
||||
@@ -124,4 +118,4 @@ class Solution {
|
||||
return windowlen == Int.max ? 0 : windowlen
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
Reference in New Issue
Block a user