Python optimal solution
For a sorted array, the left half will be in the left subtree, middle value as the root, right half in the right subtree. This holds true for every node:\n\n[1,
For a sorted array, the left half will be in the left subtree, middle value as the root, right half in the right subtree. This holds true for every node:\n\n`[1, 2, 3, 4, 5, 6, 7]` -> left: `[1, 2, 3]`, root: `4`, right: `[5, 6, 7]`\n`[1, 2, 3]` -> left: `[1]`, root: `2`, right: `[3]`\n`[5, 6, 7]` -> left: `[5]`, root: `6`, right: `[7]`\n\nMany of the approaches here suggest slicing an array recursively and passing them. However, slicing the array is expensive. It is better to pass the left and right bounds into recursive calls instead.\n\n**\uD83D\uDCAF Check out https://www.techinterviewhandbook.org for more tips and tricks by me to ace your coding interview \uD83D\uDCAF**\n\n```\nclass Solution(object):\n    def sortedArrayToBST(self, nums):\n        # Time: O(n)\n        # Space: O(n) in the case of skewed binary tree.\n        def convert(left, right):\n            if left > right:\n                return None\n            mid = (left + right) // 2\n            node = TreeNode(nums[mid])\n            node.left = convert(left, mid - 1)\n            node.right = convert(mid + 1, right)\n            return node\n        return convert(0, len(nums) - 1)\n```
[]