[LeetCode]Valid Anagram
来源:互联网 发布:js user strict 编辑:程序博客网 时间:2024/05/22 17:21
题目:判断两个字符串中的字母是否一致
分析:遍历两个串,记录每个字母的数量,最后比较各个字母的数量。
参考代码:
bool isAnagram(char* s, char* t) {
if(strlen(s)!=strlen(t))
return false;
if(strlen(s)==0)
return true;
int s1[26]={0};
int t1[26]={0};
for(int i=0;i<strlen(s);i++)
{
s1[s[i]-'a']++;
t1[t[i]-'a']++;
}
for(int j=0;j<26;j++)
{
if(s1[j]!=t1[j])
return false;
}
return true;
}
0 0
- Leetcode #242 Valid Anagram
- leetcode-242-Valid Anagram
- Leetcode: Valid Anagram
- 【leetCode】Valid Anagram
- [leetcode] 242.Valid Anagram
- leetcode 242: Valid Anagram
- 【leetcode】Valid Anagram
- [leetcode] Valid Anagram
- LeetCode Valid Anagram
- 【LeetCode】242 Valid Anagram
- [LeetCode] Valid Anagram
- leetcode: Valid Anagram
- leetCode(53):Valid Anagram
- leetcode Valid Anagram 异位体
- [leetcode 242]Valid Anagram
- leetcode Valid Anagram
- leetCode #242 Valid Anagram
- LeetCode题解:Valid Anagram
- hdoj--1231--最大连续子序列
- mayaUV展开图
- 2015-0922-osg学习历程9
- python2.4升级到python2.6
- ubuntu实用工具系列文章
- [LeetCode]Valid Anagram
- Android 核心分析 Service深入分析
- Xcode7发送HTTP请求的问题
- AngularJS体验式编程系列文章
- vs .sln与.suo文件
- 解析XML格式数据
- ZOJ.2818 Root of the Problem【开根号,水】 2015/09/22
- arduino 328P的BootLoader
- UITableView新增特性类似于qq(置顶--删除)