标签:
题目: 096 Unique Binary Search Trees
这道题目就是catalan数, 因为递归关系 为
代码为
class Solution: # @param {integer} n # @return {integer} def numTrees(self, n): # Catalan Number ans = 1 for i in range(1, n+1): ans *= (n+i)*1.0/i return int(round(ans/(n+1)))
096 Unique Binary Search Trees
标签:
原文地址:http://www.cnblogs.com/dapanshe/p/4645221.html