forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGemstones.java
More file actions
40 lines (38 loc) · 961 Bytes
/
Gemstones.java
File metadata and controls
40 lines (38 loc) · 961 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
package Strings;
import java.util.Scanner;
public class Gemstones {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s[] = new String[n];
for(int i=0;i<n;i++){
s[i] = sc.next();
}
int c;
int count=0;
int flag=1;
label1:
for(int j=0;j<26;j++){
label2:
c=0;
for(int i=0;i<n;i++){
int l = s[i].length();
label3:
for(int k=0;k<l;k++){
if(97+j==s[i].charAt(k)){
flag=1;
break;
}
flag=0;
}
if(flag==0)
break;
else
c++;
}
if(c==n)
count++;
}
System.out.println(count);
}
}