首页 > 其他 > 详细

205. Isomorphic Strings

时间:2018-05-23 11:41:20      阅读:114      评论:0      收藏:0      [点我收藏+]
 1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     bool isIsomorphic(string s, string t) 
12     {
13         int len=s.length();
14         vector<int> cs(256,-1);
15         vector<int> ct(256,-1);
16         for(int i=0;i<len;i++)
17         {
18             if(cs[s[i]]!=ct[t[i]])
19                 return false;
20             cs[s[i]]=i;
21             ct[t[i]]=i;
22         }
23         return true;
24     }
25 };

利用字符和数字间的转换,用i来进行单次检验,由于i是动态变化的,所以只有两个同形字符串能够通过检测。

205. Isomorphic Strings

原文:https://www.cnblogs.com/zhuangbijingdeboke/p/9075924.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!