Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Same Characters Check

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

Your question is Same Characters Check. 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 Amex App receives text from multiple search or support-entry surfaces. Given two strings, determine whether they contain exactly the same characters with the same frequencies, regardless of character order.

Characters are case-sensitive, and spaces and punctuation count as characters. Return True when the strings are anagrams of one another, otherwise return False.

Formal Specification

Implement same_characters(s, t):

  • Input: Two strings s and t, each containing printable characters.
  • Output: A Boolean value. Return True if both strings contain the same character counts, otherwise return False.

Constraints

  • 0 <= len(s), len(t) <= 10^5
  • Strings may contain letters, digits, spaces, and punctuation
  • Character comparison is case-sensitive
  • Do not modify either input string

Function Signature

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