Simple recursive C++ code beats 100%
\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : v
```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}\n * };\n */\nclass Solution {\npublic:\n    int rangeSumBST(TreeNode* root, int L, int R) {\n        if (root ==NULL){return 0;}\n        else if (root->val > R)\n            return rangeSumBST(root->left, L,R);\n        else if (root->val < L)\n            return rangeSumBST(root->right, L,R);\n        else\n            return root->val+rangeSumBST(root->left,L,root->val)+rangeSumBST(root->right, root->val,R);\n    }\n};\n```
[]