Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Anagram Checking

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Anagram Checking. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Shelter Insurance systems may compare customer-entered text, such as names or reference phrases, without treating capitalization or punctuation as meaningful. Given two strings, determine whether they are anagrams after normalization.

Two strings are normalized by converting letters to lowercase and ignoring every character that is not a letter or digit. Return True if the normalized strings contain exactly the same characters with the same frequencies, otherwise return False.

Formal Specification

Implement are_anagrams(s, t):

  • Input: Two strings s and t containing printable ASCII characters.
  • Output: A Boolean. Return True when the normalized versions are anagrams, and False otherwise.
  • Repeated characters must occur the same number of times. Character order does not matter.

Constraints

  • 0 <= len(s), len(t) <= 10^5
  • Inputs contain printable ASCII characters
  • Only letters and digits contribute to the comparison
  • The comparison is case-insensitive

Function Signature

def are_anagrams(s, t):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output