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

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
import { TreeNode } from "../mod.ts";
export default function pruneTree(root: TreeNode | null): TreeNode | null { if (!root) return null; const left = pruneTree(root.left); const right = pruneTree(root.right); if (root.val === 0 && !left && !right) return null;
return new TreeNode(root.val, left, right);}
masx200_leetcode_test

Version Info

Tagged at
2 years ago