【滑动窗口】最小长度连续子序列和的大小判定
/LeetCode :209Description:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn’t one, return 0 instead.
Follow up:If you have figured out the O(n) solution, try coding another solution of which the time complexity is O(n log n). /#include
notes:窗口是什么?:满足sum>=s的最小长度连续子数组窗口如何移动:若当前窗口值大于等于s,即需要缩小窗口的结束位置:即遍历数组的指针,起始位置即数组的起始位置时间复杂度:O(n) 空间复杂度:O(1)/class Solution {public: int minSubArrayLen(int s, vector
int main() { Solution ss; vector