JavaScript simple DFS solution
Runtime: 148 ms, faster than 98.20% of JavaScript online submissions for Range Sum of BST.\nMemory Usage: 66.8 MB, less than 100.00% of JavaScript online submis
Runtime: 148 ms, faster than 98.20% of JavaScript online submissions for Range Sum of BST.\nMemory Usage: 66.8 MB, less than 100.00% of JavaScript online submissions for Range Sum of BST.\n```\nfunction rangeSumBST(root, l, r) {\n  let sum = 0\n  dfs(root)\n  return sum\n  \n  function dfs(node) {\n    if (!node) {\n      return\n    }\n    \n    if (node.val < l) {\n      dfs(node.right)\n      return\n    }\n    \n    if (node.val > r) {\n      dfs(node.left)\n      return\n    }\n\n    sum += node.val\n    dfs(node.left)\n    dfs(node.right)\n  }\n}\n```
['JavaScript']