Both Iterative and Recursive solutions, 4 lines each, simple and easy to read
Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \nO(log_2(n)) where n = number of nodes for both Iterative and Recursive\n\n- Space co
# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(log_2(n))$$ where `n = number of nodes` for both Iterative and Recursive\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$ for Iterative, $$O(n)$$ where `n = number of nodes` for Recursive (due to size of callstack)\n\n# Code\n```\n// Iterative\nfunction searchBST(root: TreeNode | null, val: number): TreeNode | null {\n    while (root !== null && root.val !== val) {\n        root = val < root.val ? root.left : root.right;\n    }\n    return root;\n};\n\n// Recursive\nfunction searchBST(root: TreeNode | null, val: number): TreeNode | null {\n    if (!root) return null;\n    if (root.val === val) return root;\n    if (root.val < val) return searchBST(root.right, val);\n    if (root.val > val) return searchBST(root.left, val);\n};\n```
['TypeScript']