1、题目
https://leetcode-cn.com/problems/unique-binary-search-trees/
2、题意
题解1:
f[n]表示以n为跟节点二叉搜索树的个数
左子树有0-(n-1)个节点 右子树有(n-1)-0个节点
f[n]为所有的总合
class Solution {
public:
int numTrees(int n) {
vector<int> f(n + 1);
f[0] = 1;
for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= i; j ++ )
f[i] += f[j - 1] * f[i - j];
return f[n];
}
};