class Solution:
    def __init__(self):
        self.li = []

    def midSearch(self,node):
        if(node != None):
            self.midSearch(node.left)
            self.li.append(node.val)
            self.midSearch(node.right)

    def rangeSumBST(self, root, L, R):
        self.midSearch(root)
        count = 0
        tag = False
        for l in self.li:
            if l == L:
                tag = True
            if tag:
                count += l
            if l == R:
                tag = False
        return count

 

posted on 2018-12-13 10:50  Sempron2800+  阅读(84)  评论(0编辑  收藏  举报