From 8618c4491541b7ed4ef945952f1646909a6005d5 Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Sat, 13 Jan 2024 10:50:06 +0800 Subject: [PATCH] =?UTF-8?q?Update=200062.=E4=B8=8D=E5=90=8C=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=EF=BC=8C=E6=B7=BB=E5=8A=A0C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0062.不同路径.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/problems/0062.不同路径.md b/problems/0062.不同路径.md index 5131fdbb..207a66ee 100644 --- a/problems/0062.不同路径.md +++ b/problems/0062.不同路径.md @@ -536,8 +536,29 @@ object Solution { ``` ### c# +```csharp +// 二维数组 +public class Solution +{ + public int UniquePaths(int m, int n) + { + int[,] dp = new int[m, n]; + for (int i = 0; i < m; i++) dp[i, 0] = 1; + for (int j = 0; j < n; j++) dp[0, j] = 1; + for (int i = 1; i < m; i++) + { + for (int j = 1; j < n; j++) + { + dp[i, j] = dp[i - 1, j] + dp[i, j - 1]; + } + } + return dp[m - 1, n - 1]; + } +} +``` ```csharp +// 一维数组 public class Solution { public int UniquePaths(int m, int n)