Skip to content

Commit 5c9c4df

Browse files
committed
Runtime: 90 ms (Top 97.50%) | Memory: 51.9 MB (Top 80.00%)
1 parent cd0b0ed commit 5c9c4df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/algorithms/F/Find Two Non-overlapping Sub-arrays Each With Target Sum/Find Two Non-overlapping Sub-arrays Each With Target Sum.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// Runtime: 90 ms (Top 97.50%) | Memory: 51.9 MB (Top 80.00%)
12
var minSumOfLengths = function(arr, target) {
23
let left=0;
34
let curr=0;
45
let res=Math.min(); // Math.min() without any args will be Infinite
56
const best=new Array(arr.length).fill(Math.min());
67
let bestSoFar=Math.min()
7-
8+
89
for(let i=0;i<arr.length;i++){
910
curr+=arr[i]
1011
while(curr>target){
@@ -19,4 +20,4 @@ var minSumOfLengths = function(arr, target) {
1920
best[i]=bestSoFar;
2021
}
2122
return res===Math.min()?-1:res
22-
};
23+
};

0 commit comments

Comments
 (0)