Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Anagram Check Coding
00:00
5 left

Anagram Check Coding

EasyPython

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):
Interviewer

Your question is Anagram Check Coding. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.