Simple tree traversal
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nTraverse the whole tree and check if the value is within range. If yes, t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nTraverse the whole tree and check if the value is within range. If yes, then add it to the result.\n\n(Please upvote if it helped)\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nint res;\n\nvoid traverse(TreeNode* node, int low, int high)\n{\n    if(node->val >=low && node->val <= high)\n        res+=node->val;\n\n    if(node->left != NULL)\n        traverse(node->left, low, high);\n\n    if(node->right != NULL)\n        traverse(node->right, low, high);\n}\n\nclass Solution {\npublic:\n    int rangeSumBST(TreeNode* root, int low, int high) {\n\n        res = 0;\n        traverse(root, low, high);\n        return res;\n    }\n};\n```
['C++']