You are viewing a single comment's thread. Return to all comments →
import java.util.Scanner;
public class Solution {
static boolean isAnagram(String a, String b) { // Complete the function a = a.toLowerCase(); b = b.toLowerCase(); if(a.length()!= b.length()){ return false; } else{ char [] t = a.toCharArray(); char [] l = b.toCharArray(); java.util.Arrays.sort(t); java.util.Arrays.sort(l); return java.util.Arrays.equals(t, l); } } public static void main(String[] args) { Scanner scan = new Scanner(System.in); String a = scan.next(); String b = scan.next(); scan.close(); boolean ret = isAnagram(a, b); System.out.println( (ret) ? "Anagrams" : "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 →
import java.util.Scanner;
public class Solution {
}