feat: add dynamic programming code for JS and TS (#692)

* fix: Correcting typos

* Add JavaScript and TypeScript code of dynamic programming.

* fix: Code Style

* Change ==/!= to ===/!==
* Create const by default, change to let if necessary.

* style fix: Delete unnecessary defined type
This commit is contained in:
gaofer
2023-08-30 15:27:01 +08:00
committed by GitHub
parent bc80234994
commit f7ab4797bf
18 changed files with 1360 additions and 4 deletions

View File

@ -104,7 +104,7 @@ public class min_path_sum {
// 暴力搜索
int res = minPathSumDFS(grid, n - 1, m - 1);
System.out.println("从左上角到右下角的小路径和为 " + res);
System.out.println("从左上角到右下角的小路径和为 " + res);
// 记忆化搜索
int[][] mem = new int[n][m];
@ -112,14 +112,14 @@ public class min_path_sum {
Arrays.fill(row, -1);
}
res = minPathSumDFSMem(grid, mem, n - 1, m - 1);
System.out.println("从左上角到右下角的小路径和为 " + res);
System.out.println("从左上角到右下角的小路径和为 " + res);
// 动态规划
res = minPathSumDP(grid);
System.out.println("从左上角到右下角的小路径和为 " + res);
System.out.println("从左上角到右下角的小路径和为 " + res);
// 空间优化后的动态规划
res = minPathSumDPComp(grid);
System.out.println("从左上角到右下角的小路径和为 " + res);
System.out.println("从左上角到右下角的小路径和为 " + res);
}
}