deno.land / x / masx200_leetcode_test@10.6.5 / root-equals-sum-of-children / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
import { TreeNode } from "../binary-tree-inorder-traversal/TreeNode.ts";
export default function checkTree(root: TreeNode | null): boolean { if (!root) return false; const [sum, left, right] = [root?.val, root?.left?.val, root?.right?.val]; return ( typeof left === "number" && typeof right === "number" && sum === left + right );}
masx200_leetcode_test

Version Info

Tagged at
a year ago