Isomorphic Strings

Easy

Two strings are isomorphic when the characters of s can be replaced one-to-one to get t.

No two characters may map to the same character, and a character may map to itself.

Example 1

isIsomorphic()
Input
s = "egg", t = "add"
Output
true

Why

e → a and g → d.

Example 2

isIsomorphic()
Input
s = "foo", t = "bar"
Output
false
Constraints
1 <= s.length <= 5 * 10^4
s.length === t.length

Topics

StringsHash Table

Implement isIsomorphic in the editor and return the answer — printing it is never graded.