Gamified challenge · Hash maps
Two codes a and b (lowercase letters) are isomorphic if you can replace every letter of a by a letter so that a becomes b, where the same letter always becomes the same letter and no two different letters become the same letter. A letter may map to itself.
Write isomorphic(a, b) that returns true if such a one-to-one letter swap exists, else false. Codes of different lengths never match; two empty codes do.
Examples: egg and add match (e→a, g→d). foo and bar don't (o would need to be both a and r). ab and aa don't either: a and b can't both become a.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google