From 57025dcf3765174b867bc9710b57acf8a85b5a92 Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Tue, 16 Jan 2024 11:11:28 +0800 Subject: [PATCH] =?UTF-8?q?Update=200096.=E4=B8=8D=E5=90=8C=E7=9A=84?= =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=90=9C=E7=B4=A2=E6=A0=91=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0096.不同的二叉搜索树.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/problems/0096.不同的二叉搜索树.md b/problems/0096.不同的二叉搜索树.md index d109165b..15b99083 100644 --- a/problems/0096.不同的二叉搜索树.md +++ b/problems/0096.不同的二叉搜索树.md @@ -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]; + } +} +```