【leetcode】205-Isomorphic Strings

problem

205-Isomorphic Strings

 code

class Solution {
public:
    bool isIsomorphic(string s, string t) {
        if(s.size()!=t.size()) return false;
        int len = s.size();
        char hash_s[128] = {0}, hash_t[128] = {0};
        for(int i=0; i<len; i++)
        {
            if(hash_s[s[i]] != hash_t[t[i]]) return false;
            hash_s[s[i]] = i+1;//
            hash_t[t[i]] = i+1;//
        }
        return true;
    }
};

需要注意的

            hash_s[s[i]] = i+1;//
            hash_t[t[i]] = i+1;//

 

 

 

参考

1. Leetcode_Isomorphic Strings;

posted on 2018-12-11 20:19  鹅要长大  阅读(147)  评论(0编辑  收藏  举报

导航