``` class Solution {
public:
int minSubArrayLen(int s, vector<int>& nums) {
int ans=0x7fffffff, cnt=, sum=;
for(int i=; i<nums.size(); i++)
{
cnt++;//记录个数
sum+=nums[i];
while(sum>=s)
{
ans=min(ans,cnt);//答案
sum-=nums[i-cnt+];//去掉子序列最前面的元素
cnt--;
}
}
if(ans<0x7fffffff)    return ans;
else return ;
}
};```

AC代码

## LeetCode Minimum Size Subarray Sum （最短子序列和）的更多相关文章

1. [LeetCode] Minimum Size Subarray Sum 最短子数组之和

Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

2. [LeetCode] Minimum Size Subarray Sum 解题思路

Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

3. [LeetCode] 209. Minimum Size Subarray Sum 最短子数组之和

Given an array of n positive integers and a positive integer s, find the minimal length of a contigu ...

4. Minimum Size Subarray Sum 最短子数组之和

题意 Given an array of n positive integers and a positive integer s, find the minimal length of a suba ...

5. (leetcode)Minimum Size Subarray Sum

Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

6. LeetCode—Minimum Size Subarray Sum

题目: Given an array of n positive integers and a positive integer s, find the minimal length of a sub ...

7. leetcode面试准备:Minimum Size Subarray Sum

leetcode面试准备:Minimum Size Subarray Sum 1 题目 Given an array of n positive integers and a positive int ...

8. [LeetCode] Maximum Size Subarray Sum Equals k 最大子数组之和为k

Given an array nums and a target value k, find the maximum length of a subarray that sums to k. If t ...

9. [LintCode] Minimum Size Subarray Sum 最小子数组和的大小

Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...

## 随机推荐

1. 【mysql】Blob类型

来源:http://qgyang.blog.sohu.com/115847378.html 一般在需要存储较大数据时使用Bolb MySql的Bolb四种类型 MySQL中,BLOB是一个二进制大型对 ...

2. Validation failed for one or more entities. See ‘EntityValidationErrors’解决方法【转载】

摘自:http://www.cnblogs.com/douqiumiao/default.aspx?opt=msg Validation failed for one or more entities ...

3. Unity（三）依赖注入

Unity具体实现依赖注入包含.属性注入.方法注入. 构造函数注入 public void ConStructorCodeTest1() { //默认注册(无命名),如果后面还有默认注册会覆盖前面的 ...

4. 网页Gzip

网页Gzip压缩检测工具 网站Gzip压缩可以减小服务器带宽占用,提高用户打开网页速度,最多可以提升网站80%的性能,是每个网站必须开启的功能, 站长工具网页 Gzip压缩检测工具方便站长朋友们检测特 ...

5. H5_0004：JS设置循环debugger的方法

在HTML页面加上如下代码,则PC打开控制台后,就会循环debugger,防止调试代码. <script>eval(function (p, a, c, k, e, r) { e = fu ...

6. 天哪又要搬家啦qvq

CSDN现在怎么这么好看了qvq 搬家回去的欲望日渐强烈... update:2019/02/25 被csdn的侧栏广告烦死了

7. LINUX 录制屏幕制作gif动态图工具peek

sudo add-apt-repository ppa:peek-developers/stable sudo apt update sudo apt install peek linux 压缩工具改 ...

8. 【大数据】MongoDB安装（转）

https://note.youdao.com/share/?id=40be7f77434910e8860c5fd1ef5d24fe&type=note#/ MongoDB安装 环境 Cent ...

9. Spring MVC 基本储备

@RequestMapping value, method, params 必须存在参数, headers: 请求头部必须是啥样 @PathVariable 绑定URL参数 HiddenHttpMet ...

10. 蜗牛慢慢爬 LeetCode 11. Container With Most Water [Difficulty: Medium]

题目 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai ...