Created
December 4, 2018 03:52
-
-
Save farsialgorithm/3460a452b319b062d54ef32c539e8567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def rangeSumBST(root, L, R): | |
| def rangeSumBST_helper(node, L, R): | |
| if not node: | |
| return 0 | |
| if R<node.val: | |
| return rangeSumBST_helper(node.left, L, R) | |
| if node.val<L: | |
| return rangeSumBST_helper(node.right, L, R) | |
| return node.val + rangeSumBST_helper(node.left, L, R) +\ | |
| rangeSumBST_helper(node.right, L, R) | |
| return rangeSumBST_helper(root, L, R) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment