Basic code logic for beginners || 100ms runtime
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nAny Depth first traversal approach (Preorder traversal) \n Describe your 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nAny Depth first traversal approach (Preorder traversal) \n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(h) //height of the tree\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n *     int val;\n *     TreeNode *left;\n *     TreeNode *right;\n *     TreeNode() : val(0), left(nullptr), right(nullptr) {}\n *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}\n * };\n */\nclass Solution {\npublic:\n    int sum=0;\n    void preorder(TreeNode* root, int low, int  high){\n        if(root==NULL)\n            return;\n        if(root->val >=low && root->val <=high)\n            sum+=(root->val);\n        preorder(root->left,low,high);\n        preorder(root->right,low,high);\n    }\n\n    int rangeSumBST(TreeNode* root,int low,int high) {\n        preorder(root,low,high);        //preorder traversal \n        return sum;\n    }\n};\n```
['C', 'C++']