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 e2d8c0a commit be54fecCopy full SHA for be54fec
problems/0096.不同的二叉搜索树.md
@@ -211,6 +211,23 @@ func numTrees(n int)int{
211
}
212
```
213
214
+Javascript:
215
+```Javascript
216
+const numTrees =(n) => {
217
+ let dp = new Array(n+1).fill(0);
218
+ dp[0] = 1;
219
+ dp[1] = 1;
220
+
221
+ for(let i = 2; i <= n; i++) {
222
+ for(let j = 1; j <= i; j++) {
223
+ dp[i] += dp[j-1] * dp[i-j];
224
+ }
225
226
227
+ return dp[n];
228
+};
229
+```
230
231
232
233
-----------------------
0 commit comments