Java | DFS | BST specific | 0ms | Can merge into one line
Original codes:\n\n    public int rangeSumBST(TreeNode root, int low, int high) {\n        if (root == null)\n        \treturn 0;\n        int val = 0, left = 0
Original codes:\n```\n    public int rangeSumBST(TreeNode root, int low, int high) {\n        if (root == null)\n        \treturn 0;\n        int val = 0, left = 0, right = 0;\n        if (root.val >= low && root.val <= high)\n            val = root.val;\n        if (root.val > low)\n        \tleft = rangeSumBST(root.left, low, high);\n        if (root.val < high)\n        \tright = rangeSumBST(root.right, low, high);\n        return val + left + right;\n    }\n```\nOne line of codes (seperate to multiple lines for easy-understanding):\n```\n    public int rangeSumBST(TreeNode root, int low, int high) {\n    \treturn root == null ? 0 :\n    \t\t   (root.val >= low && root.val <= high ? root.val : 0) +\n    \t\t   (root.val > low  ? rangeSumBST(root.left,  low, high) : 0) + \n    \t\t   (root.val < high ? rangeSumBST(root.right, low, high) : 0);\n    }\n
['Depth-First Search', 'Java']