mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-24 00:16:29 +08:00
fix some typos (#1540)
Some checks failed
Dart / Dart stable on macos-latest (push) Has been cancelled
Dart / Dart stable on ubuntu-latest (push) Has been cancelled
Dart / Dart stable on windows-latest (push) Has been cancelled
.NET / .NET 8.0.x on macos-latest (push) Has been cancelled
.NET / .NET 8.0.x on ubuntu-latest (push) Has been cancelled
.NET / .NET 8.0.x on windows-latest (push) Has been cancelled
Go / Go 1.19.x on macos-latest (push) Has been cancelled
Go / Go 1.19.x on ubuntu-latest (push) Has been cancelled
Go / Go 1.19.x on windows-latest (push) Has been cancelled
Python / Python 3.10 on macos-latest (push) Has been cancelled
Python / Python 3.11 on macos-latest (push) Has been cancelled
Python / Python 3.10 on ubuntu-latest (push) Has been cancelled
Python / Python 3.11 on ubuntu-latest (push) Has been cancelled
Python / Python 3.10 on windows-latest (push) Has been cancelled
Python / Python 3.11 on windows-latest (push) Has been cancelled
Ruby / Ruby 3.3 on macos-latest (push) Has been cancelled
Ruby / Ruby 3.3 on ubuntu-latest (push) Has been cancelled
Ruby / Ruby 3.3 on windows-latest (push) Has been cancelled
Rust / build (macos-latest) (push) Has been cancelled
Rust / build (ubuntu-latest) (push) Has been cancelled
Rust / build (windows-latest) (push) Has been cancelled
Swift / Swift on macos-14 (push) Has been cancelled
Swift / Swift on ubuntu-22.04 (push) Has been cancelled
Some checks failed
Dart / Dart stable on macos-latest (push) Has been cancelled
Dart / Dart stable on ubuntu-latest (push) Has been cancelled
Dart / Dart stable on windows-latest (push) Has been cancelled
.NET / .NET 8.0.x on macos-latest (push) Has been cancelled
.NET / .NET 8.0.x on ubuntu-latest (push) Has been cancelled
.NET / .NET 8.0.x on windows-latest (push) Has been cancelled
Go / Go 1.19.x on macos-latest (push) Has been cancelled
Go / Go 1.19.x on ubuntu-latest (push) Has been cancelled
Go / Go 1.19.x on windows-latest (push) Has been cancelled
Python / Python 3.10 on macos-latest (push) Has been cancelled
Python / Python 3.11 on macos-latest (push) Has been cancelled
Python / Python 3.10 on ubuntu-latest (push) Has been cancelled
Python / Python 3.11 on ubuntu-latest (push) Has been cancelled
Python / Python 3.10 on windows-latest (push) Has been cancelled
Python / Python 3.11 on windows-latest (push) Has been cancelled
Ruby / Ruby 3.3 on macos-latest (push) Has been cancelled
Ruby / Ruby 3.3 on ubuntu-latest (push) Has been cancelled
Ruby / Ruby 3.3 on windows-latest (push) Has been cancelled
Rust / build (macos-latest) (push) Has been cancelled
Rust / build (ubuntu-latest) (push) Has been cancelled
Rust / build (windows-latest) (push) Has been cancelled
Swift / Swift on macos-14 (push) Has been cancelled
Swift / Swift on ubuntu-22.04 (push) Has been cancelled
This commit is contained in:
parent
b3b10f2300
commit
57cf6b1ea6
6 changed files with 24 additions and 24 deletions
|
@ -105,7 +105,7 @@ public class min_path_sum {
|
|||
|
||||
// 暴力搜索
|
||||
int res = MinPathSumDFS(grid, n - 1, m - 1);
|
||||
Console.WriteLine("从左上角到右下角的做小路径和为 " + res);
|
||||
Console.WriteLine("从左上角到右下角的最小路径和为 " + res);
|
||||
|
||||
// 记忆化搜索
|
||||
int[][] mem = new int[n][];
|
||||
|
@ -114,14 +114,14 @@ public class min_path_sum {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -88,17 +88,17 @@ if __name__ == "__main__":
|
|||
|
||||
# 暴力搜索
|
||||
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}")
|
||||
|
|
|
@ -76,18 +76,18 @@ if __FILE__ == $0
|
|||
|
||||
# 暴力搜索
|
||||
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
|
||||
|
|
|
@ -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)")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue