###### Minimum Size Subarray Sum
public class Solution {
public int minSubArrayLen(int s, int[] nums) {
if (nums == null || nums.length <1) {
return 0;
}
int ptr1 = 0;
int ptr2 = 0;
int sum = nums[0];
int result = Integer.MAX_VALUE;
while (ptr2 < nums.length) {
if (ptr1 == ptr2) {
if (sum >= s) {
return 1;
}
ptr2++;
if (ptr2 < nums.length) {
sum += nums[ptr2];
} else {
return result;
}
} else {
if (sum >= s) {
result = Math.min(ptr2 - ptr1 + 1, result);
sum -= nums[ptr1];
ptr1++;
} else {
ptr2++;
if (ptr2 < nums.length) {
sum += nums[ptr2];
} else {
if (ptr1 == 0) {
return 0;
} else {
return result;
}
}
}
}
}
return result;
}
}

#### LeetCode 209 - Minimum Size Subarray Sum

2015-05-12 12:50:20

#### leetcode 209 : Minimum Size Subarray Sum

2015-05-14 06:15:11

#### leetcode 209. Minimum Size Subarray Sum-子序列最小长度|双指针|二分查找

2016-06-13 22:14:10

#### LeetCode 209. Minimum Size Subarray Sum（最小子数组之和）

2016-05-04 13:17:10

#### leetcode_c++：Minimum Size Subarray Sum (209)

2016-06-18 11:51:08

#### [leetcode] 325. Maximum Size Subarray Sum Equals k 解题报告

2016-03-06 05:50:30

#### [LeetCode325] Maximum Size Subarray Sum Equals k

2016-01-08 15:34:02

#### LeetCode 325. Maximum Size Subarray Sum Equals k（和为k的最长子数组）

2016-04-26 06:10:18

#### [leetcode] 560. Subarray Sum Equals K

2017-05-03 10:34:51

#### Minimum size subarray sum

2015-05-18 06:15:08

## 不良信息举报

Minimum Size Subarray Sum