Anagram Strings

Bryam Vicente
3 min readJul 20, 2021

--

For this blog, I’ll be going over an algorithm problem in which we have to check if two strings are anagrams. I’ve solved and wrote a blog on a similar problem, be sure to check out the resource section at the bottom of this blog! Here’s a screenshot of the prompt:

An anagram is a word or phrase that’s formed by rearranging the letters of another word or phrase. The examples from the screen shot above do a great job at showing what the input and output values should be for this problem. In this case, we are checking to see if two strings are anagrams and depending on the result we should return a boolean value. The second example shows capitalization and characters such as “!” will not have any influence if the strings are anagrams.

I believe it’s important to pseudo code before starting any problem. It helps with planning and it can improve your thought process! Here’s the pseudo code that I wrote for this problem:

Because it’s a lot of pseudo code, I’ll go over the first function and then the second. I wanted to create a helper function just because it makes my code look cleaner, organized and most importantly I can debug easier! Here’s a screen shot for the first half of the pseudo code:

Now that I created the helper function, I can simply use it for the next function that I’m going to create. Here’s a screenshot for the second half of the pseudo code:

Here are the results from the examples on lines 32 -33:

For more info on .replace(), .toLowerCase(), Object.keys(), for of loops and for in loops please check the resource section below!

Resources:

--

--

No responses yet