-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3349.java
39 lines (37 loc) · 1.24 KB
/
_3349.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.fishercoder.solutions.fourththousand;
import java.util.List;
public class _3349 {
public static class Solution1 {
public boolean hasIncreasingSubarrays(List<Integer> nums, int k) {
for (int i = 0; i < nums.size(); i++) {
int count = 1;
int j = i;
boolean possible = true;
for (; j + 1 < nums.size() && count++ < k; j++) {
if (nums.get(j + 1) <= nums.get(j)) {
possible = false;
break;
}
}
boolean possibleAgain = true;
j++;
if (possible) {
count = 1;
for (; j + 1 < nums.size() && count++ < k; j++) {
if (nums.get(j + 1) <= nums.get(j)) {
possibleAgain = false;
break;
}
}
if (count < k) {
possibleAgain = false;
}
if (possibleAgain) {
return true;
}
}
}
return false;
}
}
}