deno.land / x / masx200_leetcode_test@10.6.5 / path-sum / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { TreeNode } from "../binary-tree-inorder-traversal/TreeNode.ts";
export default function hasPathSum( root: TreeNode | null, targetSum: number,): boolean { if (!root) { return false; }
if (root.val == targetSum && !root.left && !root.right) return true;
return hasPathSum(root.left, targetSum - root.val) || hasPathSum(root.right, targetSum - root.val);}
masx200_leetcode_test

Version Info

Tagged at
a year ago