Skip to content

Commit bfbf393

Browse files
authored
Create 3349. Adjacent Increasing Subarrays Detection I (#906)
2 parents 089293e + 36f84ed commit bfbf393

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Solution {
2+
public:
3+
bool hasIncreasingSubarrays(vector<int>& nums, int k)
4+
{
5+
vector<int> store;
6+
nums.push_back(-1005);
7+
8+
int count = 1, n = nums.size();
9+
for(int i = 1; i < n; i++)
10+
{
11+
if(nums[i - 1] < nums[i]) count += 1;
12+
else
13+
{
14+
store.push_back(count);
15+
count = 1;
16+
}
17+
}
18+
19+
for(auto &val : store)
20+
if(val >= (k + k)) return true;
21+
22+
n = store.size();
23+
for(int i = 1; i < n; i++)
24+
if(store[i - 1] >= k and store[i] >= k)
25+
return true;
26+
return false;
27+
}
28+
};

0 commit comments

Comments
 (0)