-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathj.java
More file actions
51 lines (48 loc) · 872 Bytes
/
j.java
File metadata and controls
51 lines (48 loc) · 872 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.*;
class j
{
public static void main(String args[])
{
Scanner ob=new Scanner(System.in);
int t=ob.nextInt();
int i,j,k,max,in;
String s;
char x,y;
int a[]=new int[10000000];
while(t>0)
{
s=ob.next();
s=s+" ";
k=0;
for(i=0;i<s.length();i++)
{
x=s.charAt(i);
for(j=0;j<s.length();j++)
{
y=s.charAt(j);
if(x==y)
{
in=j-i;
a[k]=in;
k++;
}
else
{
a[k]=0;
k++;
}
}
}
max=a[0];
for(i=0;i<k;i++)
{
if(a[i]>max)
{
max=a[i];
}
}
System.out.println(max);
t--;
}
}
}