Python 3 clean solution


#1

class Solution:
# @param A : tuple of integers
# @return the root node in the tree
def sortedArrayToBST(self, arr):

    def min_tree(arr,root):

        if len(arr) == 0:
            return root

        mid = len(arr)//2
        if not root:
            root = TreeNode(arr[mid])
    
        lt = rt = None
        root.left = min_tree(arr[0:mid],lt)
        root.right = min_tree(arr[mid+1:],rt)
        return root
    
    if not arr:
        return None
    root = TreeNode(arr[len(arr)//2])
    p = root
    min_tree(arr,root)
    
    return p