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 5564e55 commit f55f979Copy full SHA for f55f979
minimum-size-subarray-sum/minimum-size-subarray-sum.java
@@ -0,0 +1,17 @@
1
+class Solution {
2
+ public int minSubArrayLen(int target, int[] nums) {
3
+
4
+ int minLength = Integer.MAX_VALUE;
5
+ int left = 0;
6
+ int sum = 0;
7
+ for(int right = 0;right < nums.length;right++){
8
+ sum += nums[right];
9
+ while(sum >= target){
10
+ minLength = Math.min( minLength, (right - left) + 1 );
11
+ sum -= nums[left++];
12
+ }
13
14
15
+ return minLength == Integer.MAX_VALUE ? 0 : minLength;
16
17
+}
0 commit comments