🔥 Python || Easily Understood ✅ || Faster than 86% || Less than 83% || Recursion
Appreciate if you could upvote this solution\n\nMethod: recursion\n\nSince nums is a sorted list, the middle element nums[len(nums)//2] must be the root node of
**Appreciate if you could upvote this solution**\n\nMethod: `recursion`\n\nSince `nums` is a sorted list, the middle element `nums[len(nums)//2]` must be the root node of `nums`.\nThus, after setting the middle element be the root, finding the middle element in the left subarry `nums[:len(nums)//2]` and right subarry `nums[len(nums)//2 + 1 : ]`\n\nFor example, `nums = [0, 1, 2, 3, 4, 5, 6, 7]`\n\n![image](https://assets.leetcode.com/users/images/9b668608-b437-47d4-8816-8dfe9dbdd318_1660126464.7137046.png)\n\n\n\n```\nclass Solution:\n    def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]:\n        total_nums = len(nums)\n        if not total_nums:\n            return None\n\n        mid_node = total_nums // 2\n        return TreeNode(\n            nums[mid_node], \n            self.sortedArrayToBST(nums[:mid_node]), self.sortedArrayToBST(nums[mid_node + 1 :])\n        )\n```\n\nTime Complexity: `O(n log n)`\nSpace Complexity: `O(n)`\n<br/>
['Recursion', 'Python']