代码重构 【Github Actions】

This commit is contained in:
github-actions[bot]
2021-07-23 15:44:19 +00:00
parent c79cac3d9c
commit f671c90754
94 changed files with 1609 additions and 2111 deletions

View File

@@ -1,10 +1,10 @@
> 如果阅读时发现错误或者动画不可以显示的问题可以添加我微信好友 **[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>进入。
#### [560. 和为K的子数组](https://leetcode-cn.com/problems/subarray-sum-equals-k/)
#### [560. 和为 K 的子数组](https://leetcode-cn.com/problems/subarray-sum-equals-k/)
**题目描述**
@@ -51,7 +51,7 @@ presum [2] = presum[1] + nums[1],presum[3] = presum[2] + nums[2] ... 所以我
例如我们需要获取 nums[2] nums[4] 这个区间的和我们则完全根据 presum 数组得到是不是有点和我们之前说的字符串匹配算法中 BM,KMP 中的 next 数组和 suffix 数组作用类似
那么我们怎么根据presum 数组获取 nums[2] nums[4] 区间的和呢见下图
那么我们怎么根据 presum 数组获取 nums[2] nums[4] 区间的和呢见下图
![前缀和](https://cdn.jsdelivr.net/gh/tan45du/github.io.phonto2@master/myphoto/前缀和.77twdj3gpkg0.png)
@@ -102,7 +102,7 @@ class Solution {
//一次遍历
for (int i = 0; i < nums.length; ++i) {
//存在时,我们用数组得值为 key索引为 value
if (map.containsKey(target - nums[i])){
if (map.containsKey(target - nums[i])){
return new int[]{i,map.get(target-nums[i])};
}
//存入值
@@ -160,7 +160,7 @@ public:
if (nums.size() == 0) {
return 0;
}
map <int, int> m;
map <int, int> m;
//细节,这里需要预存前缀和为 0 的情况,会漏掉前几位就满足的情况
//例如输入[1,1,0]k = 2 如果没有这行代码则会返回0,漏掉了1+1=2和1+1+0=2的情况
//输入:[3,1,1,0] k = 2时则不会漏掉
@@ -182,4 +182,3 @@ public:
}
};
```