class Solution {
public:
bool isAnagram(string s, string t) {
if(t=="") return s=="";
map<char,int> m_s;
map<char,int> m_t;
int i=; while(i<t.length()){
if(m_t.find(t[i]) != m_t.end()) m_t[t[i]]++;
else m_t.insert(pair<char,int>(t[i],));
i++;
} i=;
while(i<s.length()){
if(m_s.find(s[i]) != m_s.end()) m_s[s[i]]++;
else m_s.insert(pair<char,int>(s[i],));
i++;
} map<char,int >::iterator it;
for(it=m_s.begin();it!=m_s.end();it++){ //s belong t
if(m_t[it->first] != it->second)
{return false;}
} for(it=m_t.begin();it!=m_t.end();it++){ //t belong s
if(m_s[it->first] != it->second)
{return false;}
} return true; }
};
相关文章
- 使用Xcode6.1.1打包出现Your account already has a valid iOS Distribution certificate问题
- DRDB报错------0: Failure: (119) No valid meta-data signature found.
- Delphi的idhttp报IOHandler value is not valid错误的原因
- LeetCode 20 -- Valid Parentheses
- MySQL5.6 on Windows 安装失败: String was not recognized as a valid DateTime
- 【leeetcode】125-Valid Palindrome
- ACM题目————Anagram
- iOS利用Application Loader打包提交到App Store时遇到错误The filename 未命名.ipa in the package contains an invalid character(s). The valid characters are:A-Z ,a-z,0-9,dash,period,underscore,but the name cannot start w
- SQL SERVER 2008安装错误(is not a valid login or you do have permission)
- PLSQL提示“is not a valid date and time”解决办法。