【leetcode】209. 长度最小的子数组
int minSubArrayLen(int s, int* nums, int numsSize){ int i, j, sum=0, maxLen=0; int arr[50000]={0}; for (i=0; i<numsSize && maxLen!=1; i++) { sum+=nums[i]; arr[i]=sum; if(sum>=s){ if(maxLen==0) maxLen=i+1; while(arr[i]-arr[i+1-maxLen] >= s) maxLen--; } } return maxLen; }