Topic Connection
https://leetcode.com/problems/isomorphic-strings/
Isomorphic stringsdescription
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.
Class Solution {Private:typedef Unordered_map<char, char> ump;public:bool isisomorphic (string s, String t) {if (s = = T) return true; UMP A, B;int n = s.length (); for (int i = 0; i < n; i++) {char x1 = s[i], x2 = t[i];if (a.find (x1) = = A.end ()) a[x1] = X 2;else if (a[x1]! = x2) return false;if (B.find (x2) = = B.end ()) b[x2] = X1;else if (b[x2]! = x1) return false;} return true;}};
Leetcode isomorphic Strings