✅ Easy Explanation Beats 95% /w Images
A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one\n\nIf we have a strictly incr
A **height-balanced** binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one\n\nIf we have a **strictly increasing** sorted array, The **root** node value is the value in the middle, because that\'s the value that has a number of left and right values that never differ by more than one.\n\n**Example:** [1,2,3,4,5,6,7,8,9,10]\nIf the root is `5` left subtree has the following values  `left=[1,2,34]` and right subtree has the following values `right=[6,7,8,9,10]`.\nWith the same approach we used to get the root for the complete array, we can find the root value for the subtree by choosing the middle value and so on.\n\n![image](https://assets.leetcode.com/users/images/fbee35d9-58d6-4066-84dc-7f81b5a25334_1660092718.6277065.png)\n\n```python\n\nclass Solution:\n    def sortedArrayToBST(self, nums: List[int]) -> Optional[TreeNode]:\n        def traversal(left, right):\n            if left > right: # If left greater than right, it means that added all subtree values\n                return\n            index = (left + right) // 2 # Getting the middle value for the subtree root value\n            node = TreeNode(nums[index])\n            node.left = traversal(left, index-1)\n            node.right = traversal(index+1, right)\n            return node\n        return traversal(0, len(nums) - 1)\n```\n\n![image](https://assets.leetcode.com/users/images/c8ce8f16-a78d-4ea1-a66a-e0dc5fdd9645_1660093787.6140652.png)\n\n**Time Complexity:** `O(N)` We only do the recursion `N` times where `N` is the number of elements in the array\n**Space Complexity:** `O(N`)\n\n___\nIf there are any suggestions/questions/mistakes please comment below\n___\n\n
['Divide and Conquer', 'Recursion', 'Python']