You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); String a=sc.next(); String b=sc.next(); boolean res=isAnagram(a,b); if(res){ System.out.println("Anagrams"); } else{ System.out.println("Not Anagrams"); } } static boolean isAnagram(String a,String b){ a=a.toLowerCase(); b=b.toLowerCase(); if(a.length()!=b.length()){ return false; } char ch1[]=a.toCharArray(); char ch2[]=b.toCharArray(); Arrays.sort(ch1); Arrays.sort(ch2); return Arrays.equals(ch1,ch2);
} }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Anagrams
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
} }