We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c44916c commit 64cf0cfCopy full SHA for 64cf0cf
solution/0200-0299/0209.Minimum Size Subarray Sum/Solution.java
@@ -0,0 +1,20 @@
1
+class Solution {
2
+ public int minSubArrayLen(int s, int[] nums) {
3
+ int n = nums.length;
4
+ int ans = Integer.MAX_VALUE;
5
+ int start = 0, end = 0;
6
+ int sum = 0;
7
+ while (start < n) {
8
+ while (end < n && sum < s) {
9
+ sum += nums[end];
10
+ end++;
11
+ }
12
+ if (sum >= s) {
13
+ ans = Math.min(ans, end - start);
14
15
+ sum -= nums[start];
16
+ start++;
17
18
+ return ans == Integer.MAX_VALUE ? 0 : ans;
19
20
+}
0 commit comments