【leetcode】二叉搜索树的范围和

int rangeSumBST(struct TreeNode* root, int L, int R){
    if (!root) return 0;
    if (root->val < L) return rangeSumBST(root->right,L,R);
    if (root->val > R) return rangeSumBST(root->left,L,R);
    return root->val + rangeSumBST(root->left,L,R) + rangeSumBST(root->right,L,R);
}
原文地址:https://www.cnblogs.com/ganxiang/p/13646128.html