Given strings s and t, determine if they are isomorphic.
The strings is isomorphic if the characters in s can is replaced to get t.
All occurrences of a character must is replaced with another character while preserving the order of characters. No, characters may map to the same character and a character may map to itself.
For example,
Given "egg"
, "add"
return True.
given " foo "
, " bar "
, return false.
Given "paper"
, "title"
return True.
Note:
Assume both s and T have the same length.
BOOL Isisomorphic (char* s, char* t) {int letter1[256] = {0};for (int i = 0; s[i]! = ' + '; i++) {if (!letter1[s[i]]) Lett Er1[s[i]] = T[i];else if (letter1[s[i]! = T[i]) return false;} int letter2[256] = {0};for (int i = 0; T[i]! = ' + '; i++) {if (!letter2[t[i]]) letter2[t[i]] = S[i];else if (letter2[t[i ]] = S[i]) return false;} return true;}
Leetcode OJ Isomorphic Strings