java anagrams

Solutions on MaxInterview for java anagrams by the best coders in the world

showing results for - "java anagrams"
Hayden
05 Feb 2018
1import java.util.Arrays;  
2   
3public class AnagramString {  
4    static void isAnagram(String str1, String str2) {  
5        String s1 = str1.replaceAll("\\s", "");  
6        String s2 = str2.replaceAll("\\s", "");  
7        boolean status = true;  
8        if (s1.length() != s2.length()) {  
9            status = false;  
10        } else {  
11            char[] ArrayS1 = s1.toLowerCase().toCharArray();  
12            char[] ArrayS2 = s2.toLowerCase().toCharArray();  
13            Arrays.sort(ArrayS1);  
14            Arrays.sort(ArrayS2);  
15            status = Arrays.equals(ArrayS1, ArrayS2);  
16        }  
17        if (status) {  
18            System.out.println(s1 + " and " + s2 + " are anagrams");  
19        } else {  
20            System.out.println(s1 + " and " + s2 + " are not anagrams");  
21        }  
22    }  
23   
24    public static void main(String[] args) {  
25        isAnagram("Keep", "Peek");  
26        isAnagram("Mother In Law", "Hitler Woman");  
27    }  
28}  
29/*OUTPUT
30*Keep and Peek are anagrams
31*MotherInLaw and HitlerWoman are anagrams
32*/
Laure
12 Jul 2018
1    static boolean isAnagram(String a, String b) {
2        
3        String sortedA = "";
4        Object[] aArr = a.toLowerCase().chars().sorted().mapToObj(i -> (char) i).toArray();
5        for (Object o: aArr) {
6            sortedA = sortedA.concat(o.toString());
7        }
8        
9        
10        String sortedB = "";
11        Object[] bArr = b.toLowerCase().chars().sorted().mapToObj(i -> (char) i).toArray();
12        for (Object o: bArr) {
13            sortedB = sortedB.concat(o.toString());
14        }
15        
16        if(sortedA.equals(sortedB))    
17            return true;
18        else
19            return false;    
20    }
queries leading to this page
java check anagramchecking two strings are anagrams of each otherfind anagrams in javacompare two strings and find if they are anagrams java java strings anagramsstring anagramtwo string is anagram or notanagram code javahow to chwck the string is annagram or nothow to find two strings are anagrams in javaanagram in java using 2 stringsgiven two strings 2c return true if they are anagrams of one anotherhow to check two strings are anagram of each otherhow to compare two string whether they are anagram or not 3fcheck if two words are anagrams javaprogram to check whether two strings are anagramstring anagram checkjava anagramcheck for anagram stringfunction for checking two integer aas anagramprogram to check whether two strings are anagrams or not in javaanagram tester javastring are anagrams or not in javacheck whether substring string is anagram or notanagram examples in javacheck a string is anagram or notanagram program in javahow to check whether two strings are anagrams in javacheck two string are anagram or notjava anagrams codejava program to check whether two strings are anagram or notjava program to check whether a string is anagram or notjava anagram algorithmanagram in java solutionjava anagramks 5ccheck if two strings are anagrams without using array java java program to check if 2 strings are anagramschecking anagrams 28check whether two string is anagrams or not 29anagram in jva 8java anagram codeif two strings are anagramcheck if string is a anagramjava anagramscheck if two strings are anagramsjava check if two strings are anagramstwo string being anagramsanagrams code in javahow to check if a word is anagram or notjava are anegramscheck anagram in javacheck if two strings are anagrams java quicklyheck if two strings are anagrams in javavalid anagram javablanagrams javacheck if a string is an anagramprogram for anagram in javawhat is an anagram of stringwhat is anagram javawap to check whether two strings are anagram of each other or notwhat is anagram number in javablanagram in javahow to know if two strings are anagrams in javahow to find anagrams in java3 write a program to check whether given to strings are anagramjava program to check whether two strings are anagram stacoverflowcheck whether two strings are anagram of each other jaanagrams in java programjava anagram checkerwap to check whether two strings are anagram of each other or not in javastring anagramsanagram meaning in javajava function to check if two strings are anagramfind whether 2 given strings are anagramshow to check for an anagramhow to check if two strings are anagrams of each other in javacheck whether the three strings are anagramtwo strings are anagrams if they are permutations of each othercheck whether two strings are anagramschecking for an anagram in javajava program to check if two strings are anagrams of each otherwhat is an anagram javaanagram stringsanagrams of a string in javacheck if 2 strings are anagrams javatwo string anagram javacheck two strings are anagramcheck if word is anagram of anothertwo words are anagramsjava program for anagramanagram sringanagrams program in javais 2 string anagram in javaanagram stringhow do you check if two strings are anagrams of each other 3fanagram checksfind anagrams in a string javahow to check if strings are anagramsanagram of string in javaanagram in javawap using java to check if two strings are anagrams of each other2 sting anagram javacheck if anagram javawrite a program to find whether the given string is the anagram of the first string in javadetermine whether two words are anagramsis annagram function javafind the strings are anagrams 3ffind two strings are anagramsanagramin javahow to find anagrams of a string in javagenerating anagrams javajava anagrammsimple anagram program in javaanagrame java programmecheck if a string is anagramcheck anagramprogram to check if two strings are anagrams in javacheck if two string are anagramfind all anagrams in a string javabest anagram program in javatwo strings are anagrams or not in javahow to check if two strings are anagrams of each otherfind whether 2 given strings are anagrams check whether two strings are anagram of each othercheck whether string is anagram or notfind if strings are anagrams including spaceshow to check if two given string is the anagram of each otheramagram javaanagram algorithm javastring anagram in javaanagram program in java using arraycheck if two strings are anagrams javaanagram java codehow to check if two string are anagramhow to find anagrams of in string in javaprogram to find if two strings are anagramsfind if two strings are anagramsgiven two words 2c check if they are anagrams of each otherchecking anagram in javacheck if strings are anagramswrite a java program to check if the two strings are anagrams java program to check if two strings are anagramscheck two strings are anagrams in javacheck if 2 stringsa re anagrams2 strings are anagramanagram or not or not in javacheck if two strings are anagrams of each otherhow to check if two string are anagram in javawhat is anagram stringanagram problem in javacheck s string is an anagram in javaanagram of stringwhat is an anagram stringhow do you check if two strings are anagrams of each other in javajava anagrams programcheck whether a given string is an anagram or notwhat is anagrams in javahow to check anagram in javaanagram logic in javahow to check if two strings are anagrams in javawrite a simple anagram detector with arrays javawrite a program to get two strings as input from the user the program should check if both the strings contains the same letters note 3a both the string values will be in lowercase how to compare anagram in a string in javawhat is anagram in javais anagram javafinding anagrams in javawhat 27s anagram in javaanagram java programhow do you check if two strings are anagrams of each other 3f 28solution 29find anagram of a string in javatwo strings are anagramsanagrammi javawrite a java program to check given two strings contain the same text or not in javawrite a simple anagram detector javajava anagram exampleanagram program javajava check if two string anagramsanagram of two strings in javacompare two string anagrams program in java usong throwsgiven two words check if they are anagrams of each otherare the 2 strings anagramhow to decide two strings are anagrams in javahow to determine if two strings are anagram of one another in javaanagrams javajava string anagramanagram in jaawrite a program to check anagram strings in javaanagram jjava anagram programanagram java solutionanagram string in javacheck if words are anagrams javaanagram checker javaanagram program in java 8anagram javaare 2 string anagramanagrams in javaanagram with one letter different javaanagram progarm javaanagrams of a word javajava program to check two strings are anagrams or notto check whether 2 strings are anagram or not in javawrite a java program to check if two strings are anagram in java 3fcheck if he anagarams of one strings are in anothersimple java program for anagramwhat is mean by the anagrams in javaanagram program for strings in javajava program to anagrama program to check anagram in javajava program to print anagramsanagrams stringanagram strings exampleanagram in a javacheck if string is anagramanagram code in javafind if strings are anagrams including spaesanagram example in javaanagramma in javaanagram of a string in java13 write a function to check if two strings are anagrams or not 3fhow to check two strings are anagramcheck whether 2 strings are anagram of each otheranagram two string in javafind anagrams of a string javahow to check the anagrams for string in javachecking anagrams in javajava anagrams