-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTarantino.java
More file actions
executable file
·92 lines (66 loc) · 2.21 KB
/
Tarantino.java
File metadata and controls
executable file
·92 lines (66 loc) · 2.21 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.util.Scanner;
public class Tarantino {
public static void main(String args[])
{
//We need T,n,may be a double array or a single array in another form
Scanner in = new Scanner(System.in);
//Boolean array to display yes or no
boolean answer[] = new boolean[100];
//Chapter array to store sequence of chapters
int chapters[] = new int[500];
// Number of test cases input;
int T = in.nextInt();
if (T>0&&T<=100)
{
//This loop is for number of test cases
for(int j=0;j<T;j++)
{ answer[j]=true;
//Number of chapters
int N = in.nextInt();
if(N>=2&&N<=100)
{
//We need to enter chapter series
for (int i = 0; i <N; i++) {
chapters[i] = in.nextInt();
/**
* condition 1
* checking chapter no should less than no.of chapters
*/
if (chapters[i]>N)
answer[j]=false;
}
/**
* condition 2
* checking duplicates
*/
for(int i=0;i<N;i++){
for (int k=i+1;k<N;k++)
{
if(chapters[k]==chapters[i])
answer[j]=false;
}
}
/**
* condition 3
* check whether array is in sorted manner
*/
int temp=0;
for (int k=0;k<N;k++)
{
if(chapters[k]==k+1)
temp++;
}
if(temp==N)
answer[j]=false;
}
}
}
for (int i=0;i<T;i++)
{
if(answer[i])
System.out.println("yes");
else
System.out.println("no");
}
}
}