码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode() Issomorphic Strings

时间:2015-11-26 01:02:50      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

bool isIsomorphic(string s, string t) {
         int size=s.size();
         if (size==0)
            return true;
        char ch[128],ismap[128];
        for(int i=0;i<128;i++)
        {`enter code here`
            ch[i]=-1;
            ismap[i]=-1;
        }
        bool flag=true;
        for(int i=0;i<size;i++)
        {
            if(ch[s[i]]==-1&&ismap[t[i]]==-1)
            {
                ch[s[i]]=t[i];
                ismap[t[i]]=s[i];

            }else if(ch[s[i]]!=t[i]||ismap[t[i]]!=s[i])
            {
                flag=false;
                break;
            }
        }
        return flag;
    }

  我还是很难理解这样的思想。我的88ms的就不贴了

LeetCode() Issomorphic Strings

标签:

原文地址:http://www.cnblogs.com/yanqi110/p/4996361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!