242. Valid Anagram
道县网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联公司成立于2013年到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司。
Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.
Note:
You may assume the string contains only lowercase alphabets.
Follow up:
What if the inputs contain unicode characters? How would you adapt your solution to such case?
class Solution { public: bool isAnagram(string s, string t) { if(s.size() != t.size()) { return false; } else { int sBit[26] = {0};//记录每个字母出现的次数 int tBit[26] = {0}; const char * sp = s.c_str(); const char * tp = t.c_str(); for(int i = 0; i < s.size() ; i++) { sBit[*(sp+i) - 'a']++; tBit[*(tp+i) - 'a']++; } for(int j = 0; j < 26;j++) { if(sBit[j] != tBit[j]) { return false; } } return true; } } };
2016-08-05 13:52:07
网站栏目:leetCode242.ValidAnagram合法的由颠倒字母顺序而构成的字sort
网页地址:https://www.cdcxhl.com/article16/pdejdg.html
成都网站建设公司_创新互联,为您提供网站策划、小程序开发、网站设计公司、手机网站建设、品牌网站制作、面包屑导航
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联