Java Anagrams ⬀
Two strings, a and b, are called anagrams if they contain all the same
characters in the same frequencies. For this challenge, the test is not
case-sensitive. For example, the anagrams of CAT are CAT, ACT, tac,
TCA, aTC, and CtA.
Complete the isAnagram function in the editor.
isAnagram has the following parameters:
string a: the first stringstring b: the second string
boolean: Ifaandbare case-insensitive anagrams, return true. Otherwise, return false.
- The first line contains a string
a. - The second line contains a string
b.
1 ≤ length(a), length(b) ≤ 50- Strings
aandbconsist of English alphabetic characters. - The comparison should NOT be case sensitive.
anagram
margana
Anagrams
| Character | Frequency: anagram |
Frequency: margana |
|---|---|---|
| A or a | 3 | 3 |
| G or g | 1 | 1 |
| N or n | 1 | 1 |
| M or m | 1 | 1 |
| R or r | 1 | 1 |
The two strings contain all the same letters in the same frequencies, so we print "Anagrams".
anagramm
marganaa
Not Anagrams
| Character | Frequency: anagramm |
Frequency: marganaa |
|---|---|---|
| A or a | 3 | 4 |
| G or g | 1 | 1 |
| N or n | 1 | 1 |
| M or m | 2 | 1 |
| R or r | 1 | 1 |
The two strings don't contain the same number of a's and m's, so we print "Not Anagrams".
Hello
hello
Anagrams
| Character | Frequency: Hello |
Frequency: hello |
|---|---|---|
| E or e | 1 | 1 |
| H or h | 1 | 1 |
| L or l | 2 | 2 |
| O or o | 1 | 1 |
The two strings contain all the same letters in the same frequencies, so we print "Anagrams".