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

Function getTabu

javascript/0494-target-sum.js:189–197  ·  view source on GitHub ↗
(nums, total)

Source from the content-addressed store, hash-verified

187 new Array((total + 1) << 1).fill(0); /* Time O(M) | Space O(M) */
188
189var getTabu = (nums, total) => {
190 const tabu = initTabu(total); /* Time O(M) | Space O(M) */
191 const [left, right] = [total + nums[0], total - nums[0]];
192
193 tabu[left] = 1; /* | Space O(M) */
194 tabu[right] += 1; /* | Space O(M) */
195
196 return tabu;
197};
198
199var search = (nums, total, tabu) => {
200 for (let i = 1; i < nums.length; i++) {

Callers 1

findTargetSumWaysFunction · 0.70

Calls 1

initTabuFunction · 0.70

Tested by

no test coverage detected