3 line code lmaooooo.... DFS
I don\'t think this code requires intiution but for beginner here is the brute force first approach all you need to calculate sum right? so what you could do is
**I don\'t think this code requires intiution but for beginner here is the brute force first approach all you need to calculate sum right? so what you could do is check if your root value is lie b/w the range just add it in your answer and call on your left and right childs and add their answer too return the answer**\n\n\n**since it\'s BST we can improve our logic check if your root->val is greater than high? if yes this means no need to call on right child it will never give you an answer so call on only left now check if root->val is less than low? if yes no need to call on left it won\'t give you an answer so call on right only now if both the cases are not true it means your root value is lie  b/w range so add root->val in your answer and call on left and right simple that\'s it bois/girls.......... don\'t forget to upvote \n```\nclass Solution {\npublic:\n    int rangeSumBST(TreeNode* root, int low, int high) {\n        if(!root)return 0;\n        if(root->val>high)return rangeSumBST(root->left, low,high);\n        else if(root->val<low)return rangeSumBST(root->right,low,high);\n        else return root->val + rangeSumBST(root->left, low,high) + rangeSumBST(root->right,low,high);\n    }\n};\n```
[]