dsa · easy
Isomorphic Strings
s and t have the same length. They are isomorphic when you can replace every character of s to obtain t, with two rules: each character maps to exactly one character, and no two characters map to the same character. A character may map to itself.
Arguments
s— first string; each of its characters maps to one character of tt— second string, same length as s
Example
s = "egg", t = "add": e→a, g→d → true.
s = "foo", t = "bar": o would have to become both a and r → false.
s = "paper", t = "title" → true.
Constraints
1 <= s.length <= 5 * 10^4 t.length == s.length s and t contain lowercase English letters. Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: 'egg' 'add' Expected: true
Example 2
Input: 'foo' 'bar' Expected: false
Example 3
Input: 'paper' 'title' Expected: true