Created
January 14, 2022 16:59
-
-
Save sahasourav17/eee8e3281fafd0cb2401e7764673c266 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
def anagrams(s1,s2): | |
""" | |
As seen in method 2, we first check if both strings have the | |
same length because if they're not it's impossible for them | |
to be anagrams. | |
""" | |
if len(s1) != len(s2): | |
return False | |
#comparing dictionaries with equality operator | |
return Counter(s1) == Counter(s2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment