-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnagram.java
More file actions
31 lines (25 loc) · 770 Bytes
/
Anagram.java
File metadata and controls
31 lines (25 loc) · 770 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
import java.util.Scanner;
public class Anagram {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String s2 = sc.nextLine();
boolean f=ianagram(s,s2);
if(f==true){
System.out.println("its a anagram");
}
else
System.out.println("not a anagram");
}
public static boolean ianagram(String s,String s2){
int[] count = Frequencyofstring.frequency(s);
System.out.println();
int[] count1 = Frequencyofstring.frequency(s2);
for (int i = 0; i < count.length; i++) {
if(count[i]!=count1[i]){
return false;
}
}
return true;
}
}