Created
May 18, 2015 23:35
-
-
Save emad-elsaid/823221ee72be30c403ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <map> | |
using namespace std; | |
class Solution { | |
public: | |
bool isIsomorphic(string s, string t) { | |
map<char, char> convert; | |
map<char, char> rconvert; | |
for(int i=0; i<s.length(); i++){ | |
if(convert.find(s[i])==convert.end() && rconvert.find(t[i])==rconvert.end() ){ | |
convert[s[i]] = t[i]; | |
rconvert[t[i]] = s[i]; | |
}else if(convert[s[i]] != t[i]){ | |
return false; | |
} | |
} | |
return true; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment