Python3 Simple Recursive 97% w/ Explanation
create a new node with the middle value of the array\n- for the left child, call the function again - passing the the left half of the array\n- for the right ch
- create a new node with the middle value of the array\n- for the left child, call the function again - passing the the left half of the array\n- for the right child, call the function again - passing the right half of the array\n- important to not include the middle value when passing in these new subarrays\n- this continues until the subarrays are 0, where we can no longer create any new nodes\n- once all the children are filled we can return the node\n```\ndef sortedArrayToBST(self, nums: List[int]) -> TreeNode:\n        def traverse(arr):\n            if not arr: return\n            m = (len(arr) - 1)//2\n            node = TreeNode(arr[m])\n            node.left = traverse(arr[:m])\n            node.right = traverse(arr[m+1:])\n            return node\n        return traverse(nums)\n```\n\nUpdated Solution\n* Previously, we would splice the array into halves and pass them into the function. However this process is O(k) time to make the subarray and will occupy O(k) time of each stack call - k being the length of the subarray, thus making the algorithm less efficent than it could potentially be. \n* A solution is to have a left and right pointer that will keep track of the beginning and end of the subarray. This way do not take any additonal time splicing the subarray.\n* Thanks to akashgkrishnan for pointing out the problem with the previous code.\n```\ndef sortedArrayToBST(self, nums: List[int]) -> TreeNode:\n        def traverse(l, r):\n            if l > r: return\n            m = (r + l)//2\n            node = TreeNode(nums[m])\n            node.left = traverse(l, m - 1)\n            node.right = traverse(m + 1, r)\n            return node\n        return traverse(0, len(nums) - 1)\n```
['Divide and Conquer', 'Recursion', 'Python', 'Python3']