Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created May 18, 2015 23:35
Show Gist options
  • Save emad-elsaid/823221ee72be30c403ec to your computer and use it in GitHub Desktop.
Save emad-elsaid/823221ee72be30c403ec to your computer and use it in GitHub Desktop.
#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