Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Anagram Validation

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

Your question is Anagram Validation. 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

Cargill systems may compare text fields such as shipment labels or reference values. Given two strings, determine whether they are valid anagrams of each other.

Two strings are valid anagrams when they contain exactly the same lowercase English letters with the same frequencies. The order of characters may differ, but every character in one string must appear the same number of times in the other. Do not ignore spaces, punctuation, or letter casing because inputs contain only lowercase English letters.

Formal Specification

Implement are_anagrams(s, t), where s and t are strings. Return True if t is an anagram of s; otherwise, return False.

Constraints

  • 0 <= len(s), len(t) <= 5 * 10^4
  • s and t contain only lowercase English letters
  • Return a Boolean value
  • The input strings may have different lengths

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