We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd52399 commit 1a7763dCopy full SHA for 1a7763d
209. Minimum Size Subarray Sum
@@ -0,0 +1,18 @@
1
+class Solution {
2
+ public int minSubArrayLen(int target, int[] nums) {
3
+ int currSum = 0, window = Integer.MAX_VALUE;
4
+ int start = 0, end = 0;
5
+
6
+ for(end = 0; end < nums.length; end++){
7
+ currSum += nums[end];
8
+ while(currSum >= target){
9
+ window = Math.min(window, end-start+1);
10
+ currSum -= nums[start];
11
+ start++;
12
+ }
13
14
15
+ return window == Integer.MAX_VALUE ? 0 : window;
16
17
18
+}
0 commit comments