diff --git a/codes/csharp/chapter_dynamic_programming/min_path_sum.cs b/codes/csharp/chapter_dynamic_programming/min_path_sum.cs index bfb75291b6..a02f655f47 100644 --- a/codes/csharp/chapter_dynamic_programming/min_path_sum.cs +++ b/codes/csharp/chapter_dynamic_programming/min_path_sum.cs @@ -105,7 +105,7 @@ public void Test() { // 暴力搜索 int res = MinPathSumDFS(grid, n - 1, m - 1); - Console.WriteLine("从左上角到右下角的做小路径和为 " + res); + Console.WriteLine("从左上角到右下角的最小路径和为 " + res); // 记忆化搜索 int[][] mem = new int[n][]; @@ -114,14 +114,14 @@ public void Test() { Array.Fill(mem[i], -1); } res = MinPathSumDFSMem(grid, mem, n - 1, m - 1); - Console.WriteLine("从左上角到右下角的做小路径和为 " + res); + Console.WriteLine("从左上角到右下角的最小路径和为 " + res); // 动态规划 res = MinPathSumDP(grid); - Console.WriteLine("从左上角到右下角的做小路径和为 " + res); + Console.WriteLine("从左上角到右下角的最小路径和为 " + res); // 空间优化后的动态规划 res = MinPathSumDPComp(grid); - Console.WriteLine("从左上角到右下角的做小路径和为 " + res); + Console.WriteLine("从左上角到右下角的最小路径和为 " + res); } } diff --git a/codes/dart/chapter_dynamic_programming/min_path_sum.dart b/codes/dart/chapter_dynamic_programming/min_path_sum.dart index 43c5bdece8..5dca91952c 100644 --- a/codes/dart/chapter_dynamic_programming/min_path_sum.dart +++ b/codes/dart/chapter_dynamic_programming/min_path_sum.dart @@ -103,18 +103,18 @@ void main() { // 暴力搜索 int res = minPathSumDFS(grid, n - 1, m - 1); - print("从左上角到右下角的做小路径和为 $res"); + print("从左上角到右下角的最小路径和为 $res"); // 记忆化搜索 List> mem = List.generate(n, (i) => List.filled(m, -1)); res = minPathSumDFSMem(grid, mem, n - 1, m - 1); - print("从左上角到右下角的做小路径和为 $res"); + print("从左上角到右下角的最小路径和为 $res"); // 动态规划 res = minPathSumDP(grid); - print("从左上角到右下角的做小路径和为 $res"); + print("从左上角到右下角的最小路径和为 $res"); // 空间优化后的动态规划 res = minPathSumDPComp(grid); - print("从左上角到右下角的做小路径和为 $res"); + print("从左上角到右下角的最小路径和为 $res"); } diff --git a/codes/go/chapter_dynamic_programming/min_path_sum_test.go b/codes/go/chapter_dynamic_programming/min_path_sum_test.go index f40f375db0..53ecb1a79e 100644 --- a/codes/go/chapter_dynamic_programming/min_path_sum_test.go +++ b/codes/go/chapter_dynamic_programming/min_path_sum_test.go @@ -20,7 +20,7 @@ func TestMinPathSum(t *testing.T) { // 暴力搜索 res := minPathSumDFS(grid, n-1, m-1) - fmt.Printf("从左上角到右下角的做小路径和为 %d\n", res) + fmt.Printf("从左上角到右下角的最小路径和为 %d\n", res) // 记忆化搜索 mem := make([][]int, n) @@ -31,13 +31,13 @@ func TestMinPathSum(t *testing.T) { } } res = minPathSumDFSMem(grid, mem, n-1, m-1) - fmt.Printf("从左上角到右下角的做小路径和为 %d\n", res) + fmt.Printf("从左上角到右下角的最小路径和为 %d\n", res) // 动态规划 res = minPathSumDP(grid) - fmt.Printf("从左上角到右下角的做小路径和为 %d\n", res) + fmt.Printf("从左上角到右下角的最小路径和为 %d\n", res) // 空间优化后的动态规划 res = minPathSumDPComp(grid) - fmt.Printf("从左上角到右下角的做小路径和为 %d\n", res) + fmt.Printf("从左上角到右下角的最小路径和为 %d\n", res) } diff --git a/codes/python/chapter_dynamic_programming/min_path_sum.py b/codes/python/chapter_dynamic_programming/min_path_sum.py index 9cc449216c..41d451b268 100644 --- a/codes/python/chapter_dynamic_programming/min_path_sum.py +++ b/codes/python/chapter_dynamic_programming/min_path_sum.py @@ -88,17 +88,17 @@ def min_path_sum_dp_comp(grid: list[list[int]]) -> int: # 暴力搜索 res = min_path_sum_dfs(grid, n - 1, m - 1) - print(f"从左上角到右下角的做小路径和为 {res}") + print(f"从左上角到右下角的最小路径和为 {res}") # 记忆化搜索 mem = [[-1] * m for _ in range(n)] res = min_path_sum_dfs_mem(grid, mem, n - 1, m - 1) - print(f"从左上角到右下角的做小路径和为 {res}") + print(f"从左上角到右下角的最小路径和为 {res}") # 动态规划 res = min_path_sum_dp(grid) - print(f"从左上角到右下角的做小路径和为 {res}") + print(f"从左上角到右下角的最小路径和为 {res}") # 空间优化后的动态规划 res = min_path_sum_dp_comp(grid) - print(f"从左上角到右下角的做小路径和为 {res}") + print(f"从左上角到右下角的最小路径和为 {res}") diff --git a/codes/ruby/chapter_dynamic_programming/min_path_sum.rb b/codes/ruby/chapter_dynamic_programming/min_path_sum.rb index a18fc7b168..b6396dbca9 100644 --- a/codes/ruby/chapter_dynamic_programming/min_path_sum.rb +++ b/codes/ruby/chapter_dynamic_programming/min_path_sum.rb @@ -76,18 +76,18 @@ def min_path_sum_dp_comp(grid) # 暴力搜索 res = min_path_sum_dfs(grid, n - 1, m - 1) - puts "从左上角到右下角的做小路径和为 #{res}" + puts "从左上角到右下角的最小路径和为 #{res}" # 记忆化搜索 mem = Array.new(n) { Array.new(m, - 1) } res = min_path_sum_dfs_mem(grid, mem, n - 1, m -1) - puts "从左上角到右下角的做小路径和为 #{res}" + puts "从左上角到右下角的最小路径和为 #{res}" # 动态规划 res = min_path_sum_dp(grid) - puts "从左上角到右下角的做小路径和为 #{res}" + puts "从左上角到右下角的最小路径和为 #{res}" # 空间优化后的动态规划 res = min_path_sum_dp_comp(grid) - puts "从左上角到右下角的做小路径和为 #{res}" + puts "从左上角到右下角的最小路径和为 #{res}" end diff --git a/codes/swift/chapter_dynamic_programming/min_path_sum.swift b/codes/swift/chapter_dynamic_programming/min_path_sum.swift index 640633acf4..5c7823d5c1 100644 --- a/codes/swift/chapter_dynamic_programming/min_path_sum.swift +++ b/codes/swift/chapter_dynamic_programming/min_path_sum.swift @@ -105,19 +105,19 @@ enum MinPathSum { // 暴力搜索 var res = minPathSumDFS(grid: grid, i: n - 1, j: m - 1) - print("从左上角到右下角的做小路径和为 \(res)") + print("从左上角到右下角的最小路径和为 \(res)") // 记忆化搜索 var mem = Array(repeating: Array(repeating: -1, count: m), count: n) res = minPathSumDFSMem(grid: grid, mem: &mem, i: n - 1, j: m - 1) - print("从左上角到右下角的做小路径和为 \(res)") + print("从左上角到右下角的最小路径和为 \(res)") // 动态规划 res = minPathSumDP(grid: grid) - print("从左上角到右下角的做小路径和为 \(res)") + print("从左上角到右下角的最小路径和为 \(res)") // 空间优化后的动态规划 res = minPathSumDPComp(grid: grid) - print("从左上角到右下角的做小路径和为 \(res)") + print("从左上角到右下角的最小路径和为 \(res)") } }