Programming Languages
Python
Subjective
Sep 30, 2025
Write a Python function to check if two strings are anagrams.
Detailed Explanation
def are_anagrams(str1, str2):\n # Method 1: Sort characters\n return sorted(str1.lower()) == sorted(str2.lower())\n\n# Method 2: Count characters\nfrom collections import Counter\ndef are_anagrams(str1, str2):\n return Counter(str1.lower()) == Counter(str2.lower())
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts