长度最小的子数组
Submit solution
Points:
10
Time limit:
1.0s
Memory limit:
4M
Author:
Problem type
Allowed languages
C++
长度最小的子数组
给定两个正整数 \(n\) ,\(k\) 和一个正整数数组\(s\),整数数组里面有\(n\)个整数。找出该数组中满足其和 \( \ge k\)的长度最小的连续子数组。 如果不存在符合条件的连续子数组,返回 0。
示例:
输入:
6 7
2 3 1 2 4 3
输出:
2
解释:
子数组 [4,3] 是该条件下的长度最小的连续子数组。
*如果数组里面含有负数的话,该怎么办?滑动窗口算法还适用吗?
Comments