LeetCode242:Valid Anagram
2016-03-04 09:43
302 查看
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.
bool isAnagram(char* s, char* t) { int count[26]={0}; if(strlen(s)==0&&strlen(t)==0) { return true; } for(int i=0;i<strlen(t);i++) { count[t[i]-'a']++; } for(int i=0;i<strlen(s);i++) { count[s[i]-'a']--; } for(int i=0;i<26;i++) { if(count[i]!=0) { return false; } } return true; }
相关文章推荐
- 在2016年必火的这些 Android 技术
- 解决虚拟机进入windows,oxc000035a问题。
- python爬虫基础知识
- 递归法将整数转换为字符串
- ManagementObjectSearcher的使用
- MATLAB排序函数
- 2016-03-04 动态数组的实现方式
- Android 状态栏通知Notification、NotificationManager详解
- Git分布式工作流程
- php调用webservices操作
- apache
- 改变android控件颜色
- HDU 1402 A * B Problem Plus(FFT)
- 如何安全退出已调用多个Activity的Application?
- 第三章 文件IO复习
- Json 讲解
- Windows下虚拟机安装Ubuntu15.10 Destop简易操作过程
- Ubuntu Remmina 远程桌面提示 “无法连接到RDP服务器”
- AQS源码分析(超时、中断与其他)
- zend framework中使用memcache的方法