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

Function dfs

javascript/0513-find-bottom-left-tree-value.js:20–31  ·  view source on GitHub ↗
(node, level)

Source from the content-addressed store, hash-verified

18 let deepestLevel = -Infinity;
19
20 const dfs = (node, level) => {
21 if (!node.left && !node.right) {
22 if (level > deepestLevel) {
23 leftVal = node.val;
24 deepestLevel = level;
25 }
26 return;
27 }
28
29 node.left && dfs(node.left, level + 1);
30 node.right && dfs(node.right, level + 1);
31 };
32
33 dfs(root, 0);
34 return leftVal;

Callers 1

findBottomLeftValueFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected