[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #149 from wangxinalex/patch-3
Browse files Browse the repository at this point in the history
Update 01.Linear-DP-01.md
  • Loading branch information
itcharge committed Jul 4, 2024
2 parents 381b4c8 + e6237f7 commit 850391c
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

- 如果 $nums[j] < nums[i]$,则 $nums[i]$ 可以接在 $nums[j]$ 后面,此时以 $nums[i]$ 结尾的最长递增子序列长度会在「以 $nums[j]$ 结尾的最长递增子序列长度」的基础上加 $1$,即:$dp[i] = dp[j] + 1$。

- 如果 $nums[j] \le nums[i]$,则 $nums[i]$ 不可以接在 $nums[j]$ 后面,可以直接跳过。
- 如果 $nums[j] \ge nums[i]$,则 $nums[i]$ 不可以接在 $nums[j]$ 后面,可以直接跳过。

综上,我们的状态转移方程为:$dp[i] = max(dp[i], dp[j] + 1), 0 \le j < i, nums[j] < nums[i]$。

Expand Down

0 comments on commit 850391c

Please sign in to comment.