Is Anagram

In this lesson, you will learn how to determine if a string is an anagram of another string or not.

In this lesson, we will determine whether two strings are anagrams of each other.

Simply put, an anagram is when two strings can be written using the same letters.

Examples:

"rail safety" = "fairy tales"
"roast beef" = "eat for BSE"

It sometimes changes a proper noun or personal name into a sentence:

"William Shakespeare" = "I am a weakish speller"
"Madam Curie" = "Radium came"

We will write two solutions to this problem. The first one will be concise, while the second one will be more robust and efficient. Both of these approaches involve normalizing the input string, which means converting them into lowercase and removing all the characters which are not alphanumeric.

Let’s get started with the first approach.

Implementation

Solution 1

Get hands-on with 1200+ tech skills courses.