Bug fixes and improvements (#1348)

* Add "reference" for EN version. Bug fixes.

* Unify the figure reference as "the figure below" and "the figure above".
Bug fixes.

* Format the EN markdown files.

* Replace "" with <u></u> for EN version and bug fixes

* Fix biary_tree_dfs.png

* Fix biary_tree_dfs.png

* Fix zh-hant/biary_tree_dfs.png

* Fix heap_sort_step1.png

* Sync zh and zh-hant versions.

* Bug fixes

* Fix EN figures

* Bug fixes

* Fix the figure labels for EN version
This commit is contained in:
Yudong Jin
2024-05-06 14:44:48 +08:00
committed by GitHub
parent 8e60d12151
commit c4a7966882
99 changed files with 615 additions and 259 deletions

View File

@ -31,7 +31,7 @@ function coinChangeDP(coins, amt) {
return dp[n][amt] !== MAX ? dp[n][amt] : -1;
}
/* 零钱兑换:状态压缩后的动态规划 */
/* 零钱兑换:空间优化后的动态规划 */
function coinChangeDPComp(coins, amt) {
const n = coins.length;
const MAX = amt + 1;
@ -61,6 +61,6 @@ const amt = 4;
let res = coinChangeDP(coins, amt);
console.log(`凑到目标金额所需的最少硬币数量为 ${res}`);
// 状态压缩后的动态规划
// 空间优化后的动态规划
res = coinChangeDPComp(coins, amt);
console.log(`凑到目标金额所需的最少硬币数量为 ${res}`);

View File

@ -30,7 +30,7 @@ function coinChangeIIDP(coins, amt) {
return dp[n][amt];
}
/* 零钱兑换 II状态压缩后的动态规划 */
/* 零钱兑换 II空间优化后的动态规划 */
function coinChangeIIDPComp(coins, amt) {
const n = coins.length;
// 初始化 dp 表
@ -59,6 +59,6 @@ const amt = 5;
let res = coinChangeIIDP(coins, amt);
console.log(`凑出目标金额的硬币组合数量为 ${res}`);
// 状态压缩后的动态规划
// 空间优化后的动态规划
res = coinChangeIIDPComp(coins, amt);
console.log(`凑出目标金额的硬币组合数量为 ${res}`);

View File

@ -82,7 +82,7 @@ function editDistanceDP(s, t) {
return dp[n][m];
}
/* 编辑距离:状态压缩后的动态规划 */
/* 编辑距离:空间优化后的动态规划 */
function editDistanceDPComp(s, t) {
const n = s.length,
m = t.length;
@ -130,6 +130,6 @@ console.log(`将 ${s} 更改为 ${t} 最少需要编辑 ${res} 步`);
res = editDistanceDP(s, t);
console.log(`${s} 更改为 ${t} 最少需要编辑 ${res}`);
// 状态压缩后的动态规划
// 空间优化后的动态规划
res = editDistanceDPComp(s, t);
console.log(`${s} 更改为 ${t} 最少需要编辑 ${res}`);

View File

@ -69,7 +69,7 @@ function knapsackDP(wgt, val, cap) {
return dp[n][cap];
}
/* 0-1 背包:状态压缩后的动态规划 */
/* 0-1 背包:空间优化后的动态规划 */
function knapsackDPComp(wgt, val, cap) {
const n = wgt.length;
// 初始化 dp 表
@ -108,6 +108,6 @@ console.log(`不超过背包容量的最大物品价值为 ${res}`);
res = knapsackDP(wgt, val, cap);
console.log(`不超过背包容量的最大物品价值为 ${res}`);
// 状态压缩后的动态规划
// 空间优化后的动态规划
res = knapsackDPComp(wgt, val, cap);
console.log(`不超过背包容量的最大物品价值为 ${res}`);

View File

@ -22,7 +22,7 @@ function minCostClimbingStairsDP(cost) {
return dp[n];
}
/* 爬楼梯最小代价:状态压缩后的动态规划 */
/* 爬楼梯最小代价:空间优化后的动态规划 */
function minCostClimbingStairsDPComp(cost) {
const n = cost.length - 1;
if (n === 1 || n === 2) {

View File

@ -69,7 +69,7 @@ function minPathSumDP(grid) {
return dp[n - 1][m - 1];
}
/* 最小路径和:状态压缩后的动态规划 */
/* 最小路径和:空间优化后的动态规划 */
function minPathSumDPComp(grid) {
const n = grid.length,
m = grid[0].length;
@ -116,6 +116,6 @@ console.log(`从左上角到右下角的最小路径和为 ${res}`);
res = minPathSumDP(grid);
console.log(`从左上角到右下角的最小路径和为 ${res}`);
// 状态压缩后的动态规划
// 空间优化后的动态规划
res = minPathSumDPComp(grid);
console.log(`从左上角到右下角的最小路径和为 ${res}`);

View File

@ -29,7 +29,7 @@ function unboundedKnapsackDP(wgt, val, cap) {
return dp[n][cap];
}
/* 完全背包:状态压缩后的动态规划 */
/* 完全背包:空间优化后的动态规划 */
function unboundedKnapsackDPComp(wgt, val, cap) {
const n = wgt.length;
// 初始化 dp 表
@ -58,6 +58,6 @@ const cap = 4;
let res = unboundedKnapsackDP(wgt, val, cap);
console.log(`不超过背包容量的最大物品价值为 ${res}`);
// 状态压缩后的动态规划
// 空间优化后的动态规划
res = unboundedKnapsackDPComp(wgt, val, cap);
console.log(`不超过背包容量的最大物品价值为 ${res}`);