We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4a7b865 commit 2680bfdCopy full SHA for 2680bfd
Algorithm/src/leetCode/subject/number51_100/_96DifferentBinarySearchTrees.java
@@ -0,0 +1,21 @@
1
+package leetCode.subject.number51_100;
2
+
3
+/**
4
+ * @author : CodeWater
5
+ * @create :2022-08-14-23:41
6
+ * @Function Description :96. 不同的二叉搜索树
7
+ */
8
+public class _96DifferentBinarySearchTrees {
9
+ class Solution {
10
+ public int numTrees(int n) {
11
+ int[] f = new int[n + 1];
12
+ f[0] = 1;
13
+ for( int i = 1 ; i <= n ; i++ ){
14
+ for( int j = 1 ; j <= i ; j++ ){
15
+ f[i] += f[j - 1] * f[i - j];
16
+ }
17
18
+ return f[n];
19
20
21
+}
0 commit comments