Update 0674.最长连续递增序列.md

This commit is contained in:
jianghongcheng
2023-06-07 03:59:52 -05:00
committed by GitHub
parent a7d546ca2a
commit c652187f74

View File

@ -204,7 +204,7 @@ public static int findLengthOfLCIS(int[] nums) {
Python
> 动态规划:
DP
```python
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int:
@ -219,8 +219,27 @@ class Solution:
return result
```
DP(优化版)
```python
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int:
if not nums:
return 0
> 贪心法:
max_length = 1
current_length = 1
for i in range(1, len(nums)):
if nums[i] > nums[i - 1]:
current_length += 1
max_length = max(max_length, current_length)
else:
current_length = 1
return max_length
```
贪心
```python
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int: