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

Function initTabu

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

Source from the content-addressed store, hash-verified

134};
135
136var initTabu = (nums, total) => {
137 const tabu = new Array(nums.length)
138 .fill() /* Time O(N) | Space O(N) */
139 .map(() =>
140 new Array((total + 1) << 1).fill(0),
141 ); /* Time O(M) | Space O(M) */
142 const [left, right] = [total + nums[0], total - nums[0]];
143
144 tabu[0][left] = 1; /* | Space O(N * M) */
145 tabu[0][right] += 1; /* | Space O(N * M) */
146
147 return tabu;
148};
149
150var search = (nums, total, tabu) => {
151 for (let i = 1; i < nums.length; i++) {

Callers 3

findTargetSumWaysFunction · 0.70
getTabuFunction · 0.70
searchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected