1. 4
    Determine if two strings are an anagram
    3m 52s

Determine if two strings are an anagram

Share this video with your friends

Send Tweet

The anagram test is commonly used to demonstrate how an naive implementation can perform significant order of magnitudes slower than an efficient one. We’ll also briefly go over why each implementation is not as efficient as you could make it.

A word is an anagram of another if you can rearrange its characters to produce the second word. Here we’ll write multiple increasingly more efficient functions that given two strings determines if they are anagrams of each other.

peterschussheim
~ 7 years ago

This was an AWESOME video! Would love more of these showing similar utilities.

Basarat Ali Syedinstructor
~ 7 years ago

Thanks 🌹. Will do ❤️

Christian Pena Valerio
~ 7 years ago

Awesome video. Shouldn't we compare the length of each word, and return false if lengths are not equal?

mrsoto
~ 7 years ago

String is iterable then you may apply for of without splitting it

mrsoto
~ 7 years ago

I prefer to use Array.from('string') to convert to an array and avoid N searchs

Yevgeniy
~ 7 years ago

modifying arguments is a bad practice

mac
~ 6 years ago

Hi Basarat, great video! Could you please give examples on when is the best to use Map?

Chris Samuel
~ 6 years ago

I notice you used Map in this video to solve the problem but in TypeScript Map is not supported and it does not look like it is going to be supported anytime soon. What would be the best way to use this?

yiling
~ 6 years ago

It would be very helpful if you could publish a working demo into github.

I would be interested to see how you compiled the Map and Array.from into ES6 and made it work, because I am experiencing " TS2495: Type 'IterableIteratorShim<number>' is not an array type or a string type" errors after installing ES6-Shim and type definition files.

Luis Avila
~ 6 years ago

hi, great , but this msg in Ide Error:(48, 27) TS2304: Cannot find name 'Map'.

Gabriel
~ 6 years ago

No need for string.split('') for (let char of word) works fine.

great video!

infctr
~ 6 years ago
<deleted>