MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / hasPathSum

Function hasPathSum

-112-Path-Sum/Path-Sum.py:1–6  ·  view source on GitHub ↗
(root, sum)

Source from the content-addressed store, hash-verified

1def hasPathSum(root, sum):
2 if not root:
3 return False
4 if not root.left and not root.right:
5 return root.val == sum
6 return hasPathSum(root.left, sum - root.val) or hasPathSum(root.right, sum - root.val)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected