245. Isomorphic Strings

MediumStringString

Given two strings s and t, return true if they are isomorphic — characters in s can be replaced to get t with a consistent one-to-one mapping (no two characters map to the same character, and each maps to exactly one). Input: '"s", "t"'.

Input: '"s", "t"'.

Output: Boolean — true or false.

Examples

Example 1
Input: "egg", "add"
Output: true
Explanation: e->a, g->d.
Example 2
Input: "foo", "bar"
Output: false
Explanation: o maps to both a and r.
Example 3
Input: "paper", "title"
Output: true
Explanation: Consistent mapping.

Constraints

Asked by

ZomatoBloombergMicrosoftAmazonGoogleMeta
Solve this problem in the editor →