Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Determine String Isomorphism

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

Your question is Determine String Isomorphism. 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

Datavant processes identity-related tokens whose literal characters may differ while their structural patterns remain equivalent. Given two strings, determine whether they are isomorphic.

Two strings are isomorphic if every character in the first string can be consistently mapped to exactly one character in the second string, and no two different characters map to the same character. Character order must be preserved, and repeated characters must repeat in the same positions.

Formal Specification

Implement is_isomorphic(s, t), where s and t are strings. Return True if they are isomorphic, otherwise return False. Treat characters as case-sensitive, and do not modify either input.

Constraints

  • 0 <= len(s), len(t) <= 5 * 10^4
  • s and t contain standard Python string characters
  • The function must return False when the lengths differ

Function Signature

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