Hook
More breakout videos from this creator.
Can you solve this Twitter interview problem? Make sure that you know how to solve this because it's a basic problem that they expect you to know. All right, today we're covering valid anagram. Given two strings s and t, return true if t is an anagram of s, and false otherwise. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. All right, example one, if our strings are anagram and nagaram, then the output should be true because they both have the same exact letters. Example two, if our strings are rat and car, the output should be false because they contain different letters. All right, so to solve this question, we know that we need some counts, so let's set up a hash map. And this hash map will store our letter and its count. Then for each character inside s, we can increment the count of that letter. Then for each character inside t, we need to subtract from our letter counts. Finally, at the end, if all the counts were zero, then we know they had the same letters. All right, let's see if this works. And there we go, we beat 99% of Python submissions. All right, follow for more and comment down below if you would have passed this interview.