You are viewing a single comment's thread. Return to all comments →
used java 15 public class Solution {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String a = sc.next(); String b = sc.next(); a=a.toLowerCase(); b=b.toLowerCase(); char a1[] = a.toCharArray(); char b1[] = b.toCharArray(); Arrays.sort(a1); Arrays.sort(b1); if(a1.length==b1.length){ if(Arrays.equals(a1,b1)){ System.out.println("Anagrams"); } else{ System.out.println("Not Anagrams"); } } else{ System.out.println("Not Anagrams"); } }
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 →
used java 15 public class Solution {