1
# Runtime: 73 ms (Top 74.11%) | Memory: 15.7 MB (Top 42.55%)2
# Definition for a binary tree node.4
# def __init__(self, val=0, left=None, right=None):10
def generateTrees(self, n: int) -> List[Optional[TreeNode]]:11
# define a sorted list of the numbers, for each num in that list , leftvalues12
# are left tree and right val are rightree, then for each number create a tree13
# assign the left and right to that root and append the root to the ans14
nums = list(range(1, n + 1))20
for i in range(len(nums)):21
leftTrees = dfs(nums[:i])22
rightTrees = dfs(nums[i + 1 :])26
root = TreeNode(nums[i])