✔️ 100% Fastest Swift Solution
\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     public var val: Int\n *     public var left: TreeNode?\n *     public var right
```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     public var val: Int\n *     public var left: TreeNode?\n *     public var right: TreeNode?\n *     public init() { self.val = 0; self.left = nil; self.right = nil; }\n *     public init(_ val: Int) { self.val = val; self.left = nil; self.right = nil; }\n *     public init(_ val: Int, _ left: TreeNode?, _ right: TreeNode?) {\n *         self.val = val\n *         self.left = left\n *         self.right = right\n *     }\n * }\n */\nclass Solution {\n    // - Complexity:\n    //   - time: O(n), where n is the length of nums.\n    //   - space: O(n), where n is the length of nums.\n\n    func sortedArrayToBST(_ nums: [Int]) -> TreeNode? {\n        helper(nums, 0, nums.count - 1)\n    }\n\n    \n    private func helper(_ nums: [Int], _ lo: Int, _ hi: Int) -> TreeNode? {\n        guard lo <= hi else { return nil }\n\n        let mid = lo + (hi - lo) / 2\n\n        let root = TreeNode(nums[mid])\n        root.left = helper(nums, lo, mid - 1)\n        root.right = helper(nums, mid + 1, hi)\n\n        return root\n    }\n\n}\n```\n\nLet me know in comments if you have any doubts. I will be happy to answer.\n\nPlease upvote if you found the solution useful.
['Swift']