Skip to content

Commit c9cba3c

Browse files
authored
Create adjacent-increasing-subarrays-detection-ii.py
1 parent 23fd658 commit c9cba3c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
# array
5+
class Solution(object):
6+
def maxIncreasingSubarrays(self, nums):
7+
"""
8+
:type nums: List[int]
9+
:rtype: int
10+
"""
11+
result = 0
12+
curr, prev = 1, 0
13+
for i in xrange(len(nums)-1):
14+
if nums[i] < nums[i+1]:
15+
curr += 1
16+
else:
17+
prev = curr
18+
curr = 1
19+
result = max(result, curr//2, min(prev, curr))
20+
return result

0 commit comments

Comments
 (0)