Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Anagram Check for Two Strings

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

Your question is Anagram Check for Two 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

PayPal may compare normalized reference strings when validating a payment request. Given two strings, determine whether they are anagrams, meaning one can be formed by rearranging all characters of the other.

The comparison is case-sensitive, and every character must be matched exactly. For this problem, inputs contain only lowercase English letters. Repeated characters must occur the same number of times.

Formal Specification

Implement is_anagram(s, t):

  • Input: two strings s and t containing zero or more lowercase English letters.
  • Output: return True if s and t are anagrams, otherwise return False.
  • The function must not modify either input string.

Constraints

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

Function Signature

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