Check whether two Strings are Anagram of each other using HashMap in Java
Write a function to check whether two given strings are an Anagram of each other or not.
An anagram of a string is another string that contains the same characters, only the order of characters can be different.
For example, “abcd” and “dabc” are an Anagram of each other.
Approach: Hashmaps can also be used to find if any two given strings are anagrams or not, by mapping the characters of each string to individual hashmaps and comparing them together.
Strings to be checked are: geeksforgeeks forgeeksgeeks The two strings are anagrams of each other Strings to be checked are: geeksforgeeks geeks The two strings are not anagram of each other
Related Article: Check whether two strings are anagram of each other
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.