class Solution {
public:
int haha[256]={0},hehe[256]={0};
bool isIsomorphic(string s, string t) {
if(s.length() != t.length()) return false;
for(int i = 0;i < s.length(); i++){
if(haha[s[i]] == 0)
haha[s[i]] = t[i];
if(hehe[t[i]] == 0)
hehe[t[i]] = s[i];
if(haha[s[i]] != t[i] || hehe[t[i]] != s[i])
return false;
}
return true;
}
};
leetcode 205. Isomorphic Strings
最新推荐文章于 2024-08-25 17:36:33 发布