Determine whether two strings can be transformed into each other with a one-to-one character mapping.
Given two strings s and t, determine whether they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t with a consistent mapping.
s must map to exactly one character in t.s may map to the same character in t.Return true if the strings are isomorphic, otherwise return false.
Two strings s and t.
Return a boolean indicating whether the strings are isomorphic.
Assume both strings consist of ASCII characters unless otherwise specified by the platform. The strings are typically of equal length for a valid isomorphism check.
Example 1
Input
s = "egg", t = "add"
Output
true
Explanation
The mapping can be e -> a and g -> d.
Example 2
Input
s = "foo", t = "bar"
Output
false
Explanation
The character o would need to map to both a and r, which is not allowed.
Example 3
Input
s = "paper", t = "title"
Output
true
Explanation
A consistent one-to-one mapping exists: p -> t, a -> i, e -> l, r -> e.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.