Skip to content

Commit

Permalink
fix some typos (#1540)
Browse files Browse the repository at this point in the history
  • Loading branch information
Transmigration-zhou authored Oct 31, 2024
1 parent b3b10f2 commit 57cf6b1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions codes/csharp/chapter_dynamic_programming/min_path_sum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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][];
Expand All @@ -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);
}
}
8 changes: 4 additions & 4 deletions codes/dart/chapter_dynamic_programming/min_path_sum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ void main() {

// 暴力搜索
int res = minPathSumDFS(grid, n - 1, m - 1);
print("从左上角到右下角的做小路径和为 $res");
print("从左上角到右下角的最小路径和为 $res");

// 记忆化搜索
List<List<int>> 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");
}
8 changes: 4 additions & 4 deletions codes/go/chapter_dynamic_programming/min_path_sum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
8 changes: 4 additions & 4 deletions codes/python/chapter_dynamic_programming/min_path_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
8 changes: 4 additions & 4 deletions codes/ruby/chapter_dynamic_programming/min_path_sum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions codes/swift/chapter_dynamic_programming/min_path_sum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
}

0 comments on commit 57cf6b1

Please sign in to comment.