Update 0096.不同的二叉搜索树,添加C#

This commit is contained in:
eeee0717
2024-01-16 11:11:28 +08:00
parent 0076152aec
commit 57025dcf37

View File

@ -328,6 +328,25 @@ object Solution {
}
}
```
### C#
```csharp
public class Solution
{
public int NumTrees(int n)
{
int[] dp = new int[n + 1];
dp[0] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= i; j++)
{
dp[i] += dp[j - 1] * dp[i - j];
}
}
return dp[n];
}
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">