Skip to content

Commit 1d6114c

Browse files
committed
Time: 1 ms (100.00%), Space: 43.7 MB (99.74%) - LeetHub
1 parent 8e17895 commit 1d6114c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution {
2+
public boolean hasIncreasingSubarrays(List<Integer> nums, int k) {
3+
4+
int n = nums.size();
5+
if(n<2*k) return false;
6+
if(k==1) return true;
7+
for(int i=0;i<n-2*k+1;i++){
8+
if(check(i,k,nums)==true){
9+
return true;
10+
}
11+
}
12+
return false;
13+
}
14+
public boolean check(int i , int k , List<Integer> nums){
15+
int n = nums.size();
16+
for(int j=i;j<i+2*k-1 && j<n-1 ;j++){
17+
int curr = nums.get(j) , next = nums.get(j+1);
18+
if(curr >=next && j!=i+k-1){
19+
return false;
20+
}
21+
if(j == i+k-1){
22+
continue;
23+
}
24+
}
25+
return true;
26+
}
27+
}

0 commit comments

Comments
 (0)