Skip to content

Commit 2680bfd

Browse files
committed
add leetcode: 96
1 parent 4a7b865 commit 2680bfd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)