Skip to content

Commit f4ff34a

Browse files
committed
674-longest-continuous-increasing-subsequence.md Added another solution in Python.
1 parent 8a9bca8 commit f4ff34a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

en/1-1000/674-longest-continuous-increasing-subsequence.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Solution {
8484
```
8585

8686
## Python
87+
### Solution 1
8788
```python
8889
class Solution:
8990
def findLengthOfLCIS(self, nums: List[int]) -> int:
@@ -99,6 +100,25 @@ class Solution:
99100
return max(dp)
100101
```
101102

103+
### Solution 2
104+
```python
105+
class Solution:
106+
def findLengthOfLCIS(self, nums: List[int]) -> int:
107+
result = 1
108+
current_length = 1
109+
110+
for i in range(1, len(nums)):
111+
if nums[i] > nums[i - 1]:
112+
current_length += 1
113+
114+
if current_length > result:
115+
result = current_length
116+
else:
117+
current_length = 1
118+
119+
return result
120+
```
121+
102122
## C++
103123
```cpp
104124
// Welcome to create a PR to complete the code of this language, thanks!

zh/1-1000/674-longest-continuous-increasing-subsequence.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Solution {
8484
```
8585

8686
## Python
87+
### Solution 1
8788
```python
8889
class Solution:
8990
def findLengthOfLCIS(self, nums: List[int]) -> int:
@@ -99,6 +100,25 @@ class Solution:
99100
return max(dp)
100101
```
101102

103+
### Solution 2
104+
```python
105+
class Solution:
106+
def findLengthOfLCIS(self, nums: List[int]) -> int:
107+
result = 1
108+
current_length = 1
109+
110+
for i in range(1, len(nums)):
111+
if nums[i] > nums[i - 1]:
112+
current_length += 1
113+
114+
if current_length > result:
115+
result = current_length
116+
else:
117+
current_length = 1
118+
119+
return result
120+
```
121+
102122
## C++
103123
```cpp
104124
// Welcome to create a PR to complete the code of this language, thanks!

0 commit comments

Comments
 (0)