Isomorphic Strings
EasyP2Coding
Two strings s and t of the same length are isomorphic if the characters of s can be replaced to get t, where every occurrence of a character is replaced by the same character, and no two different characters map to the same character. A character may map to itself.
Return true if s and t are isomorphic.
Example 1
- Input
- s = "egg", t = "add"
- Output
- true
Example 2
- Input
- s = "foo", t = "bar"
- Output
- false
Example 3
- Input
- s = "paper", t = "title"
- Output
- true
Constraints
- 1 <= s.length <= 5 * 10^4
- t.length == s.length
- s and t consist of printable ASCII characters.
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 12. ⌘Enter runs, ⌘⇧Enter submits.