Easy · Strings

Is isomorphic

Given two strings s and t of the same length, return true if the characters of s can be replaced to produce t, with every occurrence of a character replaced by the same character and no two characters replaced by the same one (a character may map to itself), and false otherwise.

Examples

Example 1

{
  "s": "egg",
  "t": "add"
}

Output: true (isomorphic)

Example 2

{
  "s": "foo",
  "t": "bar"
}

Output: false (not isomorphic)

Rebuild it in the studio

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Strings problems