-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnagrams.java
More file actions
39 lines (29 loc) · 988 Bytes
/
Anagrams.java
File metadata and controls
39 lines (29 loc) · 988 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
import java.io.*;
import java.util.*;
class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String a = sc.next();
String b = sc.next();
boolean z = false;
a = a.toLowerCase();
b = b.toLowerCase();
char[] c = a.toCharArray();
char[] d = b.toCharArray();
Arrays.sort(c);
Arrays.sort(d);
String e = new String(c);
String f = new String(d);
if(e.equals(f))
z= true;
if(z)
{
System.out.println("Anagrams");
}
else
{
System.out.println("Not Anagrams");
}
}
}