Skip to content

Commit 23fd658

Browse files
authored
Create adjacent-increasing-subarrays-detection-i.py
1 parent 5516e1d commit 23fd658

File tree

1 file changed

+21
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)