We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 281eca1 commit 3bfdd67Copy full SHA for 3bfdd67
Leet_Code/Random Problem/96-UniqueBinarySearchTrees.cpp
@@ -0,0 +1,11 @@
1
+class Solution {
2
+public:
3
+ long long numTrees(long long n) {
4
+
5
+ if(n <= 1){return 1;}
6
+ std::vector<long long> f(n + 1, 0);
7
+ f[0] = f[1] = 1;
8
+ for(int p = 2; p <= n; p++){for(int q = 0; q < p; q++){f[p] += f[q] * f[p - 1 - q];}}
9
+ return f[n];
10
+ }
11
+};
0 commit comments