forked from AllAlgorithms/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIsograms.java
More file actions
40 lines (37 loc) · 863 Bytes
/
Isograms.java
File metadata and controls
40 lines (37 loc) · 863 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
import java.lang.*;
import java.io.*;
class Isogram
{
public static boolean Check(String s){
HashSet<Character>h=new HashSet<>();
for(int i=0;i<s.length();i++){
if(h.contains(s.charAt(i))){
return false;
}
else{
h.add(s.charAt(i));
}
}
return true;
}
public static void main (String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int []arr;
try{
String st=br.readLine();
int t=Integer.parseInt(st);
for(int i=0;i<t;i++){
String a=br.readLine();
boolean l=Check(a);
if(l==true){
System.out.println(1);
}
else{
System.out.println(0);
}
}
}
catch(IOException e){ }
}
}