let hasPathSum = function(root, sum) {
if (!root) return false;
if (sum - root.val === 0 && !root.left && !root.right) return true;
return hasPathSum(root.left, sum - root.val)
|| hasPathSum(root.right, sum - root.val);
};
Categories
let hasPathSum = function(root, sum) {
if (!root) return false;
if (sum - root.val === 0 && !root.left && !root.right) return true;
return hasPathSum(root.left, sum - root.val)
|| hasPathSum(root.right, sum - root.val);
};