deno.land / x / masx200_leetcode_test@10.6.5 / evaluate-boolean-binary-tree / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { TreeNode } from "../mod.ts";import { Values } from "./Values.ts";
function evaluateTree(root: TreeNode | null): boolean { if (!root) { return false; } if (!root.left && !root.right) { return root.val === Values.True; } else { const left = evaluateTree(root.left); const right = evaluateTree(root.right); const result = root.val === Values.Or ? left || right : left && right; return result; }}export default evaluateTree;
masx200_leetcode_test

Version Info

Tagged at
a year ago