-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringPrac.java
More file actions
36 lines (27 loc) · 774 Bytes
/
Copy pathStringPrac.java
File metadata and controls
36 lines (27 loc) · 774 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
package Practice;
import java.util.Scanner;
public class StringPrac{
int p=0;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
// 12 999 1 123456 7 9998 2
String arr[]=new String[n];
int mx_len=0;
for(int i=0;i<arr.length;i++){
arr[i]=sc.next();
if(arr[i].length()>mx_len){
mx_len=arr.length;
}
}
for(int i=1;i<mx_len;i++){
int count=0;
for(int j=0;j<arr.length;j++){
if(arr[j].length()==i){
count++;
}
}
System.out.print(i+" "+(count)+" ");
}
}
}