This commit is contained in:
krahets
2024-05-06 05:27:10 +08:00
parent 2395804410
commit 7e7eb6047a
56 changed files with 3908 additions and 42257 deletions

View File

@@ -457,7 +457,7 @@ $$
=== "JS"
```javascript title="min_cost_climbing_stairs_dp.js"
/* 爬楼梯最小代价:状态压缩后的动态规划 */
/* 爬楼梯最小代价:空间优化后的动态规划 */
function minCostClimbingStairsDPComp(cost) {
const n = cost.length - 1;
if (n === 1 || n === 2) {
@@ -477,7 +477,7 @@ $$
=== "TS"
```typescript title="min_cost_climbing_stairs_dp.ts"
/* 爬楼梯最小代价:状态压缩后的动态规划 */
/* 爬楼梯最小代价:空间优化后的动态规划 */
function minCostClimbingStairsDPComp(cost: Array<number>): number {
const n = cost.length - 1;
if (n === 1 || n === 2) {

View File

@@ -1361,7 +1361,7 @@ $$
=== "JS"
```javascript title="min_path_sum.js"
/* 最小路径和:状态压缩后的动态规划 */
/* 最小路径和:空间优化后的动态规划 */
function minPathSumDPComp(grid) {
const n = grid.length,
m = grid[0].length;
@@ -1388,7 +1388,7 @@ $$
=== "TS"
```typescript title="min_path_sum.ts"
/* 最小路径和:状态压缩后的动态规划 */
/* 最小路径和:空间优化后的动态规划 */
function minPathSumDPComp(grid: Array<Array<number>>): number {
const n = grid.length,
m = grid[0].length;

View File

@@ -746,7 +746,7 @@ $$
=== "JS"
```javascript title="edit_distance.js"
/* 编辑距离:状态压缩后的动态规划 */
/* 编辑距离:空间优化后的动态规划 */
function editDistanceDPComp(s, t) {
const n = s.length,
m = t.length;
@@ -780,7 +780,7 @@ $$
=== "TS"
```typescript title="edit_distance.ts"
/* 编辑距离:状态压缩后的动态规划 */
/* 编辑距离:空间优化后的动态规划 */
function editDistanceDPComp(s: string, t: string): number {
const n = s.length,
m = t.length;

View File

@@ -1307,7 +1307,7 @@ $$
=== "JS"
```javascript title="knapsack.js"
/* 0-1 背包:状态压缩后的动态规划 */
/* 0-1 背包:空间优化后的动态规划 */
function knapsackDPComp(wgt, val, cap) {
const n = wgt.length;
// 初始化 dp 表
@@ -1329,7 +1329,7 @@ $$
=== "TS"
```typescript title="knapsack.ts"
/* 0-1 背包:状态压缩后的动态规划 */
/* 0-1 背包:空间优化后的动态规划 */
function knapsackDPComp(
wgt: Array<number>,
val: Array<number>,

View File

@@ -554,7 +554,7 @@ $$
=== "JS"
```javascript title="unbounded_knapsack.js"
/* 完全背包:状态压缩后的动态规划 */
/* 完全背包:空间优化后的动态规划 */
function unboundedKnapsackDPComp(wgt, val, cap) {
const n = wgt.length;
// 初始化 dp 表
@@ -578,7 +578,7 @@ $$
=== "TS"
```typescript title="unbounded_knapsack.ts"
/* 完全背包:状态压缩后的动态规划 */
/* 完全背包:空间优化后的动态规划 */
function unboundedKnapsackDPComp(
wgt: Array<number>,
val: Array<number>,
@@ -1417,7 +1417,7 @@ $$
=== "JS"
```javascript title="coin_change.js"
/* 零钱兑换:状态压缩后的动态规划 */
/* 零钱兑换:空间优化后的动态规划 */
function coinChangeDPComp(coins, amt) {
const n = coins.length;
const MAX = amt + 1;
@@ -1443,7 +1443,7 @@ $$
=== "TS"
```typescript title="coin_change.ts"
/* 零钱兑换:状态压缩后的动态规划 */
/* 零钱兑换:空间优化后的动态规划 */
function coinChangeDPComp(coins: Array<number>, amt: number): number {
const n = coins.length;
const MAX = amt + 1;
@@ -2190,7 +2190,7 @@ $$
=== "JS"
```javascript title="coin_change_ii.js"
/* 零钱兑换 II状态压缩后的动态规划 */
/* 零钱兑换 II空间优化后的动态规划 */
function coinChangeIIDPComp(coins, amt) {
const n = coins.length;
// 初始化 dp 表
@@ -2215,7 +2215,7 @@ $$
=== "TS"
```typescript title="coin_change_ii.ts"
/* 零钱兑换 II状态压缩后的动态规划 */
/* 零钱兑换 II空间优化后的动态规划 */
function coinChangeIIDPComp(coins: Array<number>, amt: number): number {
const n = coins.length;
// 初始化 dp 表