语言:Python
描述:使用递归实现
class Solution:
# @return an integer
def numTrees(self, n):
if n == :
return
elif n == :
return
else:
part_1 = self.numTrees(n-) *
part_2 = for i in range(,n-):
part_left = self.numTrees(i)
part_right = self.numTrees(n - - i)
part_2 += part_left * part_right return part_1 + part_2