diff --git a/README.md b/README.md deleted file mode 100644 index 7c3b229..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Algorithms 2019-2020 Python LEETCODE - -Check branches for information. \ No newline at end of file diff --git a/tree.md b/tree.md new file mode 100644 index 0000000..ce4ccf0 --- /dev/null +++ b/tree.md @@ -0,0 +1,25 @@ +# Binary tree + ++ [Path Sum](#path-sum) + +## Path Sum + +https://leetcode.com/problems/path-sum/ + +```python +# Definition for a binary tree node. +# class TreeNode(object): +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution(object): + def hasPathSum(self, root, sum): + if not root: + return False + sum -= root.val + if not root.left and not root.right: + return sum == 0 + return self.hasPathSum(root.left,sum) or self.hasPathSum(root.right,sum) + +``` \ No newline at end of file