JAVA short 0ms solution faster than 100% ✅
Runtime: 0 ms, faster than 100.00% of Java online submissions for Range Sum of BST.\nMemory Usage: 67.1 MB, less than 42.28% of Java online submissions for Rang
Runtime: 0 ms, faster than 100.00% of Java online submissions for Range Sum of BST.\nMemory Usage: 67.1 MB, less than 42.28% of Java online submissions for Range Sum of BST.\n```\nclass Solution {\n    int sum = 0;\n    int lo = 0; // low\n    int hi = 0; // and high\n    public int rangeSumBST(TreeNode root, int low, int high) {\n        lo = low;\n        hi = high;\n        addSum(root);\n        return sum;\n    }\n    \n    void addSum(TreeNode root) {\n        if (root == null) return;\n        if (root.val >= lo && root.val <= hi) { // if the root value is in the range\n            sum += root.val; // add to sum\n            addSum(root.left); // left\n            addSum(root.right); // right\n        } else if (root.val < lo) addSum(root.right); // if the root value is too small\n        else addSum(root.left); // if the root value is too big\n    }\n}\n```
['Recursion', 'Java']