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

Function pathSum

javascript/0124-binary-tree-maximum-path-sum.js:13–18  ·  view source on GitHub ↗
(root, maxValue)

Source from the content-addressed store, hash-verified

11};
12
13const pathSum = (root, maxValue) => {
14 const isBaseCase = root === null;
15 if (isBaseCase) return 0;
16
17 return dfs(root, maxValue);
18};
19
20const dfs = (node, maxValue) => {
21 const left = Math.max(0, pathSum(node.left, maxValue));

Callers 2

maxPathSumFunction · 0.85
dfsFunction · 0.85

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected