Skip to content

Commit c609600

Browse files
authored
Update 2331-evaluate-boolean-binary-tree.js
1 parent fa30ca4 commit c609600

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

javascript/2331-evaluate-boolean-binary-tree.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ var evaluateTree = function(root) {
1818
};
1919

2020
const dfs = (node) => {
21-
if (!node.left && !node.right) return (node.val) ? true : false;
22-
21+
22+
if (!node.left && !node.right && node.val) return true;
23+
if (!node.left && !node.right && !node.val) return false;
24+
2325
const is2 = (node.val === 2);
2426
if (is2) return dfs(node.left) || dfs(node.right);
2527

0 commit comments

Comments
 (0)