Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5e64245

Browse files
committed
Update 0300. 最长递增子序列.md
1 parent 23362c9 commit 5e64245

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎Solutions/0300. 最长递增子序列.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@
2727

2828
### 思路 1:动态规划
2929

30-
##### 1. 定义状态
30+
###### 1. 划分阶段
31+
32+
按照子序列的结尾位置进行阶段划分。
33+
34+
###### 2. 定义状态
3135

3236
定义状态 `dp[i]` 表示为:以 `nums[i]` 结尾的最长递增子序列长度。
3337

34-
#####2. 状态转移方程
38+
###### 3. 状态转移方程
3539

3640
一个较小的数后边如果出现一个较大的数,则会形成一个更长的递增子序列。
3741

@@ -43,11 +47,11 @@
4347

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

46-
#####3. 初始化
50+
###### 4. 初始条件
4751

4852
默认状态下,把数组中的每个元素都作为长度为 `1` 的递增子序列。即 `dp[i] = 1`
4953

50-
##### 4. 最终结果
54+
##### 5. 最终结果
5155

5256
根据我们之前定义的状态,`dp[i]` 表示为:以 `nums[i]` 结尾的最长递增子序列长度。那为了计算出最大的最长递增子序列长度,则需要再遍历一遍 `dp` 数组,求出最大值即为最终结果。
5357

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /