
Anagram check
easyAnagram check
Etsy Python Interview Question
Etsy's trust and safety team flags new shop names that are just the letters of a well-known shop name rearranged.
Write a function is_anagram(first, second) that returns True if the two strings use exactly the same letters the same number of times, and False otherwise. Both strings contain only lowercase letters.
Asked of
- Data Analyst
- Data Engineer
- Data Scientist
- ML Engineer
- AI Engineer
Example 1
Input
first = "listen", second = "silent"
Output
True
Example 2
Input
first = "rat", second = "car"
Output
False
Explanation
In the first example, "listen" and "silent" use the letters e, i, l, n, s and t once each, so they are anagrams. In the second example, "rat" has an r where "car" has a c, so they are not.
Submit also runs 4 hidden test cases that check edge cases.
Company
Etsy
Difficulty
easy
Topic
strings
Language
Python
Your code
Loading Python in the background. You can start writing.