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

Function rangeSumBST

javascript/0938-range-sum-of-bst.js:19–30  ·  view source on GitHub ↗
(root, low, high)

Source from the content-addressed store, hash-verified

17 * @return {number}
18 */
19var rangeSumBST = function (root, low, high) {
20 let total = 0;
21
22 const dfs = (node) => {
23 if (!node) return;
24 if (node.val >= low && node.val <= high) total += node.val;
25 dfs(node.left);
26 dfs(node.right);
27 };
28 dfs(root);
29 return total;
30};

Callers

nothing calls this directly

Calls 1

dfsFunction · 0.70

Tested by

no test coverage detected