mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
feat(csharp) .NET 8.0 code migration (#966)
* .net 8.0 migration * update docs * revert change * revert change and update appendix docs * remove static * Update binary_search_insertion.cs * Update binary_search_insertion.cs * Update binary_search_edge.cs * Update binary_search_insertion.cs * Update binary_search_edge.cs --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
@ -8,7 +8,7 @@ namespace hello_algo.chapter_dynamic_programming;
|
||||
|
||||
public class edit_distance {
|
||||
/* 编辑距离:暴力搜索 */
|
||||
public int EditDistanceDFS(string s, string t, int i, int j) {
|
||||
int EditDistanceDFS(string s, string t, int i, int j) {
|
||||
// 若 s 和 t 都为空,则返回 0
|
||||
if (i == 0 && j == 0)
|
||||
return 0;
|
||||
@ -30,7 +30,7 @@ public class edit_distance {
|
||||
}
|
||||
|
||||
/* 编辑距离:记忆化搜索 */
|
||||
public int EditDistanceDFSMem(string s, string t, int[][] mem, int i, int j) {
|
||||
int EditDistanceDFSMem(string s, string t, int[][] mem, int i, int j) {
|
||||
// 若 s 和 t 都为空,则返回 0
|
||||
if (i == 0 && j == 0)
|
||||
return 0;
|
||||
@ -56,7 +56,7 @@ public class edit_distance {
|
||||
}
|
||||
|
||||
/* 编辑距离:动态规划 */
|
||||
public int EditDistanceDP(string s, string t) {
|
||||
int EditDistanceDP(string s, string t) {
|
||||
int n = s.Length, m = t.Length;
|
||||
int[,] dp = new int[n + 1, m + 1];
|
||||
// 状态转移:首行首列
|
||||
@ -82,7 +82,7 @@ public class edit_distance {
|
||||
}
|
||||
|
||||
/* 编辑距离:空间优化后的动态规划 */
|
||||
public int EditDistanceDPComp(string s, string t) {
|
||||
int EditDistanceDPComp(string s, string t) {
|
||||
int n = s.Length, m = t.Length;
|
||||
int[] dp = new int[m + 1];
|
||||
// 状态转移:首行
|
||||
|
||||
Reference in New Issue
Block a user