标签:class http ble color binary solution vector public int
problem:https://leetcode.com/problems/unique-binary-search-trees/
左子树个数 * 右子树个数
class Solution { public: int numTrees(int n) { vector<int> dp(n + 1); dp[1] = 1; for(int i = 2;i <= n;i++) { dp[i] = dp[i - 1] + dp[i - 1]; for(int j = 1;j <= i - 1; j++) { dp[i] += dp[j] * dp[i - 1 - j]; } } return dp[n]; } };
[动态规划] leetcode 96 Unique Binary Search Trees
标签:class http ble color binary solution vector public int
原文地址:https://www.cnblogs.com/fish1996/p/11329808.html