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

Function update

javascript/0416-partition-equal-subset-sum.js:149–161  ·  view source on GitHub ↗
(nums, numIndex, subSetSum, tabu)

Source from the content-addressed store, hash-verified

147};
148
149var update = (nums, numIndex, subSetSum, tabu) => {
150 const num = numIndex - 1;
151 const prevNum = nums[num];
152
153 for (let subSet = 0; subSet <= subSetSum; subSet++) {
154 /* Time O(M) */
155 const isNumGreater = subSet < prevNum;
156
157 tabu[numIndex][subSet] = isNumGreater /* Space O(N * M) */
158 ? tabu[num][subSet]
159 : tabu[num][subSet] || tabu[num][subSet - prevNum];
160 }
161};
162
163/**
164 * DP - Bottom Up

Callers 1

searchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected