170. Check if Strings are Isomorphic

EasyStringString

Given two strings s and t, determine if they are isomorphic.

Two strings are isomorphic if the characters in s can be replaced to get t, where each character in s maps to exactly one character in t and no two characters in s map to the same character in t. A character may map to itself.

Return 'true' if isomorphic, 'false' otherwise.

Input: Two comma-separated strings: s and t (same length).

Output: Return 'true' if the strings are isomorphic, otherwise 'false'.

Examples

Example 1
Input: egg,add
Output: true
Explanation: e→a, g→d — bijective mapping exists.
Example 2
Input: foo,bar
Output: false
Explanation: o→a and o→r is a contradiction.
Example 3
Input: paper,title
Output: true
Explanation: p→t, a→i, e→l, r→e — valid mapping.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →