#70 Isomorphic Strings

Companies:
Yandex
Themes:
AlgorithmsStringsPractice

Two strings s and t are given. Determine whether they are isomorphic.

Two strings s and t are called isomorphic if the characters in string s can be replaced to obtain string t, while:

  • All occurrences of a replaced character must be replaced with the same replacement character.
  • No two different characters may be replaced with the same character.
  • A character may be replaced with itself.
/*
Examples:
s = "egg", t = "add" -> True
s = "foo", t = "bar" -> False
s = "paper", t = "title" -> True
*/
public boolean isIsomorphic(String s, String t) {
    ...
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in