MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / canSplit

Function canSplit

javascript/0410-split-array-largest-sum.js:24–37  ·  view source on GitHub ↗
(largest)

Source from the content-addressed store, hash-verified

22 }
23
24 function canSplit(largest) {
25 let splitCount = 0;
26 let currSum = 0;
27
28 for (let i = 0; i < nums.length; i++) {
29 currSum += nums[i];
30 if (currSum > largest) {
31 currSum = nums[i];
32 splitCount++;
33 }
34 }
35
36 return splitCount + 1 <= k;
37 }
38
39 return result;
40};

Callers 2

splitArrayMethod · 0.85
splitArrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected