Merge pull request #2133 from jianghongcheng/master

merge
This commit is contained in:
程序员Carl
2023-06-12 07:00:09 +08:00
committed by GitHub
5 changed files with 201 additions and 38 deletions

View File

@@ -208,7 +208,7 @@ public static int findLengthOfLCIS(int[] nums) {
Python
> 动态规划:
DP
```python
class Solution:
def findLengthOfLCIS(self, nums: List[int]) -> int:
@@ -223,8 +223,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: