-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrainbow.java
More file actions
64 lines (59 loc) · 2.04 KB
/
Copy pathrainbow.java
File metadata and controls
64 lines (59 loc) · 2.04 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.Arrays;
import java.util.Scanner;
class rainbow {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for (int i = 0; i < t; i++) {
int size = scan.nextInt();
int array[] = new int[size];
int array1[] = new int[size];
boolean flag = true;
int count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0, count6 = 0, count7 = 0,count8 = -1;
for (int j = 0; j < size; j++) {
array[j] = scan.nextInt();
array1[size - j - 1] = array[j];
}
for (int d = 0; d < size; d++) {
if (array[d] > 7) {
flag = false;
}
}
if(flag){
for(int k=0;k<size;k++){
if (array[k] == 1) {
count1++;
} else if (array[k] == 2) {
count2++;
} else if (array[k] == 3) {
count3++;
} else if (array[k] == 4) {
count4++;
} else if (array[k] == 5) {
count5++;
} else if (array[k] == 6) {
count6++;
} else if(array[k]==7){
count7++;
}
}
}
// System.out.println(Arrays.toString(array1));
// System.out.println(Arrays.toString(array));
if (count1 != 0 && count2 != 0 && count3 != 0 && count4 != 0 && count5 != 0 && count6 != 0 && count7 != 0) {
if (Arrays.equals(array1, array)) {
flag = true;
} else {
flag = false;
}
} else {
flag = false;
}
if (flag == true) {
System.out.println("yes");
} else {
System.out.println("no");
}
}
}
}