| 10 | |
| 11 | #Solution : Inorder traversal and range(DFS) |
| 12 | class Solution: |
| 13 | def rangeSumBST(self, root: TreeNode, L: int, R: int) -> int: |
| 14 | output=[] |
| 15 | self.inorder(root,output) |
| 16 | sum=L+R |
| 17 | for i in range(len(output)): |
| 18 | if output[i]>L and output[i]<R: |
| 19 | sum+=output[i] |
| 20 | return sum |
| 21 | def inorder(self,root,output): |
| 22 | if root == None: |
| 23 | return |
| 24 | else: |
| 25 | self.inorder(root.left,output) |
| 26 | output.append(root.val) |
| 27 | self.inorder(root.right,output) |
nothing calls this directly
no outgoing calls
no test coverage detected