Ctrl K

Same Letter Cipher

Easy
A simple cipher replaces every character with some other character (or keeps it as is): all occurrences of a character are replaced the same way, and no two different characters may turn into the same one. You are given strings plain and coded of equal length. Return True if coded can be produced from plain by such a cipher, and False otherwise.
Example 1
plain="level", coded="rotor" → True

l→r, e→o, v→t: each letter always becomes the same one and different letters become different ones. True.

Example 2
plain="moon", coded="noon" → False

m→n, but also n→n: two different letters would turn into the same one. False.

Example 3
plain="ab", coded="aa" → False
Constraints
  • 1 ≤ len(plain) ≤ 5·10⁴
  • len(coded) == len(plain)
  • Both strings consist of ASCII characters
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasySame Letters, Reshuffled EasySame When Flipped EasyShuffle Into a Palindrome EasyWords Following a Letter Pattern Easy
loading Python…
Input
plain="level", coded="rotor"
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.