1 2 3 4 5 6 7 8 9 10 11 12 13 14
| bool isIsomorphic(string s, string t) { map<char, char> t2s, s2t; for (int i = 0; i < s.size(); i++) { char a = s[i], b = t[i]; if (s2t.contains(a) && s2t[a] != b || t2s.contains(b) && t2s[b] != a) return false; s2t[a] = b; t2s[b] = a; } return true; }
|