Skip to content
DeepForgeby svx
All problems
EasyAlgorithmsal-011

Anagram Check

Problem

Return True if strings s and t are anagrams, meaning they contain exactly the same characters with the same multiplicities.

Comparison is case-sensitive and every character counts, including spaces and punctuation. For example, listen and silent are anagrams.

Hint

Count characters of one string, then consume the counts with the other.

Test cases

case 1
in: ["listen","silent"]
expected: true
case 2
in: ["hello","world"]
expected: false
case 3
in: ["",""]
expected: true
case 4
in: ["aab","aba"]
expected: true
case 5
in: ["abc","ab"]
expected: false
Starter codePython
def is_anagram(s, t):
    # Your code here
    pass

5 test cases · run your code against them in the editor