Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Check Anagram Strings

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

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

The Eight Sleep app receives short text labels from different parts of the product experience. Given two strings, determine whether they are anagrams: they must contain exactly the same lowercase English letters with the same frequencies, possibly in a different order.

Formal Specification

Implement are_anagrams(s, t).

  • Input: Two strings s and t containing only lowercase English letters.
  • Output: Return True if the strings are anagrams. Otherwise, return False.
  • Character order does not matter, but character frequency does. Do not ignore spaces, punctuation, or letter case, although the constraints exclude those characters.

Constraints

  • 0 <= len(s), len(t) <= 10^5
  • s and t contain only lowercase English letters
  • The input strings must not be modified

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