-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmazon_1.java
More file actions
42 lines (42 loc) · 818 Bytes
/
Amazon_1.java
File metadata and controls
42 lines (42 loc) · 818 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
package practicetime;
import java.util.Scanner;
public class Amazon_1
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int c=0,count=0,max=0;
System.out.print(" Enter the Number of Test Cases - ");
int n=sc.nextInt();
String s[]=new String[n];
for(int k=0;k<n;k++)
{
System.out.print(" Enter the "+(k+1)+" String - ");
s[k]=sc.next();
for(int i=0;i<s[k].length();i++)
{
c=(int)s[k].charAt(i);
for(int j=i+1;j<s[k].length();j++)
{
if((c+1)==(int)s[k].charAt(j))
{
count++;
c++;
}
else
{
break;
}
}
//System.out.println(count);
if(count>max)
{
max=count;
}
count=0;
}
System.out.println(" Frequency of "+(k+1)+" String is - "+(max+1));
}
sc.close();
}
}