您的位置:首页 > 其它

Leetcode 205. Isomorphic Strings

2018-01-01 14:41 435 查看
这题和Leetcode290. Word Pattern思路一样。

class Solution {
public:
bool isIsomorphic(string s, string t) {
map<char,char>m1, m2;
for(int i=0; i<s.size(); ++i)
{
if(m1.count(s[i]) && m1[s[i]]!=t[i] || m2.count(t[i]) && m2[t[i]]!=s[i] )
return false;
m1[s[i]]=t[i];
m2[t[i]]=s[i];
}
return true;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  leetcode