- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1566.java
26 lines (24 loc) · 849 Bytes
/
_1566.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
packagecom.fishercoder.solutions.secondthousand;
importjava.util.Arrays;
publicclass_1566 {
publicstaticclassSolution1 {
publicbooleancontainsPattern(int[] arr, intm, intk) {
for (inti = 0; i < arr.length - m; i++) {
int[] pattern = Arrays.copyOfRange(arr, i, i + m);
inttimes = 1;
for (intj = i + m; j < arr.length; j += m) {
int[] candidate = Arrays.copyOfRange(arr, j, j + m);
if (Arrays.equals(pattern, candidate)) {
times++;
if (times == k) {
returntrue;
}
} else {
break;
}
}
}
returnfalse;
}
}
}