Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Anagram Check Coding

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

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

In SLB's DELFI environment, two generated identifiers may contain the same characters in a different order. Write a function that determines whether two strings are anagrams.

Two strings are anagrams when they contain exactly the same characters with the same frequencies. Treat uppercase and lowercase letters as different characters, and treat spaces, punctuation, and digits as ordinary characters. The strings do not need to have the same order.

Formal Specification

Implement are_anagrams(s, t).

  • Input: Two strings s and t.
  • Output: Return True if t is an anagram of s; otherwise, return False.

Constraints

  • 0 <= len(s), len(t) <= 5 * 10^4
  • Strings contain printable ASCII characters
  • Matching is case-sensitive
  • Spaces, punctuation, and digits are treated as ordinary characters

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