/**
 * struct TreeNode {
 *	int val;
 *	struct TreeNode *left;
 *	struct TreeNode *right;
 *	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 * };
 */
#include <vector>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param root TreeNode类 
     * @param low int整型 
     * @param high int整型 
     * @return int整型
     */
    int rangeSumBST(TreeNode* root, int low, int high) {
        // write code here
        if(!root)
            return 0;

        int left = rangeSumBST(root->left, low, high);
        int right = rangeSumBST(root->right, low, high);
        int t=0;
        if(root->val>=low && root->val<=high)
            t=root->val;

        return t+left+right;
    }
};