Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TreeNode:
- def __init__(self, val=0, left=None, right=None):
- self.val = val
- self.left = left
- self.right = right
- def easy_solution(r, high, low):
- sum = 0
- if(root.val >= low and root.val <= high):
- sum += root.val
- if(root.left != None):
- sum += self.rangeSumBST(root.left, low, high)
- if(root.right != None):
- sum += self.rangeSumBST(root.right, low, high)
- return sum
Advertisement
Add Comment
Please, Sign In to add comment