C++ || Easy to Understand || Explained
Intuition\n Describe your first thoughts on how to solve this problem. \nCase-1 : If currVal is in range [>=low && <= high] \n         Then traverse both the le
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**Case-1** : If currVal is in range [>=low && <= high] \n         Then **traverse both** the left and right subtree\n\n**Case-2 :** If [currVal <= low] \nThen traverse only the right subtree\n\n**Case-3 :** If [currVal >= high]\nThen traverse only the left subtree\n        \n\n\n\n\n# Code\n```\nclass Solution {\npublic:\n    int solve(TreeNode* curr, int& low, int& high)\n    {\n        if (curr == NULL) return 0;\n        \n        int ans = 0;\n        bool isInRange = false;\n        if (curr->val >= low && curr->val <= high) \n        {\n            isInRange = true;\n            ans += curr->val;\n        }\n        \n        if (isInRange || (curr->val <= low)) ans += solve(curr->right, low, high);\n        if (isInRange || (curr->val >= high)) ans += solve(curr->left, low, high);\n        return ans;\n    }\n    int rangeSumBST(TreeNode* root, int low, int high) \n    {\n        return solve(root, low, high);\n        \n    }\n};\n```
['Recursion', 'C', 'C++']