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

Function update

javascript/0494-target-sum.js:211–226  ·  view source on GitHub ↗
(num, total, tabu, temp)

Source from the content-addressed store, hash-verified

209};
210
211var update = (num, total, tabu, temp) => {
212 for (let sum = -total; sum <= total; sum++) {
213 /* Time O(M) */
214 const isInvalid = tabu[sum + total] <= 0;
215 if (isInvalid) continue;
216
217 const dpSum = tabu[sum + total];
218 const left = sum + num + total;
219 const right = sum - num + total;
220
221 temp[left] += dpSum; /* Space O(M) */
222 temp[right] += dpSum; /* Space O(M) */
223 }
224
225 return temp;
226};

Callers 1

searchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected