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

Function search

javascript/0312-burst-balloons.js:15–33  ·  view source on GitHub ↗
(
    nums,
    left = 1,
    right = nums.length - 2,
    memo = initMemo(nums),
)

Source from the content-addressed store, hash-verified

13};
14
15var search = (
16 nums,
17 left = 1,
18 right = nums.length - 2,
19 memo = initMemo(nums),
20) => {
21 const isBaseCase = right - left < 0;
22 if (isBaseCase) return 0;
23
24 const hasSeen = memo[left][right] !== -1;
25 if (hasSeen) return memo[left][right];
26
27 return dfs(
28 nums,
29 left,
30 right,
31 memo,
32 ); /* Time O(N * N * N) | Space O((N * N) + HEIGHT) */
33};
34
35var initMemo = (nums) =>
36 new Array(nums.length)

Callers 2

maxCoinsFunction · 0.70
dfsFunction · 0.70

Calls 2

initMemoFunction · 0.70
dfsFunction · 0.70

Tested by

no test coverage detected