26 lines
526 B
Go
26 lines
526 B
Go
// Package q3349 implements a solution for https://leetcode.com/problems/adjacent-increasing-subarrays-detection-i/
|
|
package q3349
|
|
|
|
func hasIncreasingSubarrays(nums []int, k int) bool {
|
|
seqLen := 1
|
|
prevSeqTail := -2
|
|
for i := 1; i < len(nums); i++ {
|
|
if nums[i-1] < nums[i] {
|
|
seqLen++
|
|
if seqLen == k && prevSeqTail == i-k {
|
|
return true
|
|
}
|
|
if seqLen >= 2*k {
|
|
return true
|
|
}
|
|
} else {
|
|
if seqLen >= k {
|
|
prevSeqTail = i - 1
|
|
}
|
|
seqLen = 1
|
|
}
|
|
}
|
|
return k == 1
|
|
}
|
|
|
|
var _ = hasIncreasingSubarrays
|