Leetcode 242 Valid Anagram
来源:互联网 发布:sql count 用法 编辑:程序博客网 时间:2024/06/07 06:04
Leetcode 242 Valid Anagram
#include <string>#include <algorithm>#include <vector>using namespace std;class Solution {public: bool isAnagram(string s, string t)//too slow { sort(s.begin(),s.end()); sort(t.begin(),t.end()); return (s == t); } bool isAnagram2(string s, string t) //faster { vector<int> lettercount(26,0); if(s.length() != t.length()) return false; for(int i = 0;i < s.length();i ++) lettercount[s[i] - 'a'] ++; for(int i = 0;i < t.length();i ++) { lettercount[t[i] - 'a'] --; if(lettercount[t[i] - 'a'] < 0) return false; } return true; }};
阅读全文
0 0
- Leetcode #242 Valid Anagram
- leetcode-242-Valid Anagram
- leetcode 242: Valid Anagram
- 【LeetCode】242 Valid Anagram
- [leetcode 242]Valid Anagram
- leetCode #242 Valid Anagram
- Leetcode #242 Valid Anagram
- LeetCode 242 Valid Anagram
- [LeetCode 242] Valid Anagram
- LeetCode(242)Valid Anagram
- leetcode[242] Valid Anagram
- leetcode 242 :Valid Anagram
- LeetCode 242----Valid Anagram
- 【LeetCode】242Valid Anagram
- Leetcode #242 Valid Anagram
- LeetCode 242:Valid Anagram
- LeetCode 242 Valid Anagram
- LeetCode 242:Valid Anagram
- RecyclerVieW自定义华丽的分割线
- 批量生产删除ASM物理文件的脚本
- 第三周——项目一—顺序表的基本运算(3)
- CXTPRibbonBar添加系统菜单时候,会出现白条
- License Key Formatting 问题及解法
- Leetcode 242 Valid Anagram
- Training Neural Networks with Very Little Data -- A Draft径向变换
- Leetcode 400 Nth Digit
- USB充电,标准充电器,非标准充电器的区别
- Leetcode 441 Arranging Coins
- 如何将拷贝过来的代码实现高亮
- Leetcode 561 Array Partition I
- 前端技术介绍,跟我学响应式布局
- 关于pod导入protocolBuffers使用问题