|Anagram Check
All Challenges

Anagram Check

MediumStrings

Given two strings s and t, return True if t is an anagram of s, otherwise False.


An anagram uses the same characters the same number of times — just rearranged. Ignore spaces and treat the comparison as case-insensitive.


You'd use this in autocomplete engines, word game validation, and spell checkers.

Examples

Input: is_anagram("listen", "silent")
Output: True
Same letters, rearranged
Input: is_anagram("hello", "world")
Output: False
Different characters
Input: is_anagram("Astronomer", "Moon starer")
Output: True
Ignore spaces, case-insensitive
Input: is_anagram("rat", "car")
Output: False
Different characters

Constraints

  • 1 <= len(s), len(t) <= 5,000
  • Ignore spaces; treat as case-insensitive
pythoneditor
Loading Python runtime…