Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

最优子结构原理和 dp 数组遍历方向 :: labuladong的算法小抄 #759

Closed
labuladong opened this issue Feb 5, 2022 · 10 comments
Closed

Comments

@labuladong
Copy link
Owner

labuladong commented Feb 5, 2022

文章链接点这里:最优子结构原理和 dp 数组遍历方向

评论礼仪 见这里,违者直接拉黑。

Copy link

2、遍历结束后,存储结果的那个位置必须已经被及算出来。计算,有个错别字

@labuladong
Copy link
Owner Author

感谢指出,已修复

@labuladong labuladong transferred this issue from labuladong/myblog Mar 16, 2022
Copy link

1、遍历的过程中,所需的状态必须是已经计算出来的。

2、遍历结束后,存储结果的那个位置必须已经被计算出来。

下面来距离解释上面两个原则是什么意思。东哥,这里具体解释不小心打成距离了哦

@labuladong
Copy link
Owner Author

@Maschinist-LZY 谢谢指出,已修复~

Copy link

打卡,感谢!

Copy link

感觉 现在在写遍历方向就好了。 在确定遍历方向之前 是不是需要最终的结果存在那个位置以及base case的位置 然后才能根据那两条rules 去确定遍历方向

Copy link

yokiizx commented Jun 28, 2022

斜着遍历没看懂....

Copy link

// 斜着遍历数组
for (int l = 2; l <= n; l++) {
    for (int i = 0; i <= n - l; i++) {
        int j = l + i - 1;
        // 计算 dp[i][j]
    }
}

斜着遍历数组这里是不是应该写为l=1开始,这样的画是正对角线,否则是正对角线上面一条斜线,不知道dong哥想表达的是那个

@labuladong
Copy link
Owner Author

@cillian-bao 理解你的意思,正对角线上的是 base case,所以我们进行状态转移是从正对角线上面一条开始

Copy link

billwhn commented Sep 4, 2022

显然,至少有两条路径:(i, j) -> #1 -> #4 和 (i, j) -> #3 -> #3

第一种是不是写错了

Repository owner locked and limited conversation to collaborators Sep 6, 2022
@labuladong labuladong converted this issue into discussion #1001 Sep 6, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants