-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuiz6.java
More file actions
27 lines (23 loc) · 700 Bytes
/
Quiz6.java
File metadata and controls
27 lines (23 loc) · 700 Bytes
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
public class Quiz6 {
public static boolean isSubSeqOf(int[] a, int[] b){
for (int i = 0; i < b.length-a.length; i++) {
int found=0;
for (int j = 0; j <a.length ; j++) {
if(b[i+j]==a[j]){
found++;
}
}
if(found==a.length){
return true;
}
}
return false;
}
public static void main(String[] args) {
int[] lst1 = {5, 2, 1};
int[] lst2 = {4, 2, 3, 8, 0, 5, 2, 1, 9, 7};
System.out.println(isSubSeqOf(lst1,lst2));
int[] lst3 = {0,2,1};
System.out.println(isSubSeqOf(lst3,lst2));
}
}