两个字符串是否是变位词(直接lintcode敲代码,一次通过,噢耶!)
2016-07-26 18:55
579 查看
class Solution { public: /** * @param s: The first string * @param b: The second string * @return true or false */ bool anagram(string s, string t) { // write your code here map<char,int> m1,m2; for(auto c:s){ m1[c]++; } for(auto b:t){ m2[b]++; } for(auto a:m1){ if(m1[a.first]!=m2[a.first]) return false; } return true; } };
相关文章推荐
- GO语言高并发学习心得体会
- [置顶] 恶意代码--逆向分析基础入门
- GO语言Comma-ok断言
- python find()用法
- 33个超级有用必须要收藏的PHP代码样例
- php坑
- C#中如何截取Windows消息来触发自定义事件
- java cef3 禁止右键菜单项
- MATLAB - contour函数
- struts2生成验证码
- java多线程-生产者消费者经典问题
- UVa 1593 Allgnment of Code代码对齐( 习题5-1)
- (11)SSH整合
- Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
- java之File
- Python 导入机制 - import hook
- phpstorm快捷键
- JAVA笔记之FileInputStream
- ContentProvider:内容提供者
- 编程之美2.12--快速寻找满足条件的两个数