Advertisement
Arnab_Manna

anagram

Mar 18th, 2023
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Solution {
  5.  
  6.     public static void main(String[] args) {
  7.         /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
  8.         Scanner in=new Scanner(System.in);
  9.         String a=in.nextLine().toLowerCase();
  10.         String b=in.nextLine().toLowerCase();
  11.        
  12.         char b1[]=a.toCharArray();
  13.         char a1[]=b.toCharArray();
  14.        
  15.         Arrays.sort(b1);
  16.         Arrays.sort(a1);
  17.        
  18.         if (Arrays.equals(a1,b1))
  19.             System.out.println("Anagrams");
  20.         else
  21.             System.out.println("Not Anagrams");
  22.        
  23.        
  24.        
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement