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; }
};

Valid Anagram的更多相关文章

  1. 【09_242】Valid Anagram

    Valid Anagram My Submissions Question Total Accepted: 43694 Total Submissions: 111615 Difficulty: Ea ...

  2. leetcode面试准备:Valid Anagram

    leetcode面试准备:Valid Anagram 1 题目 Given two strings s and t, write a function to determine if t is an ...

  3. 242. Valid Anagram(C++)

    242. Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. ...

  4. 22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)

    22. 242. Valid Anagram(由颠倒字母顺序而构成的字) Given two strings s and t, write a function to determine if t i ...

  5. 【LeetCode】242. Valid Anagram (2 solutions)

    Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. For ...

  6. [leetcode]242. Valid Anagram验证变位词

    Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...

  7. leetcdoe Valid Anagram

    题目连接 https://leetcode.com/problems/valid-anagram/ Valid Anagram Description Given two strings s and ...

  8. LN : leetcode 242 Valid Anagram

    lc 242 Valid Anagram 242 Valid Anagram Given two strings s and t, write a function to determine if t ...

  9. LeetCode_242. Valid Anagram

    242. Valid Anagram Easy Given two strings s and t , write a function to determine if t is an anagram ...

  10. LeetCode 242. 有效的字母异位词(Valid Anagram)

    242. 有效的字母异位词 LeetCode242. Valid Anagram 题目描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s ...

随机推荐

  1. centos 下 django 1.8 配置好后 admin 后台无法显示 样式解决办法

    解决前 解决命令 [root@ayibang-server static]# cat /etc/nginx/conf.d/office_djaong_uvpv.conf server { listen ...

  2. Python模块 (xlsxwriter)

    xlsxwriter是python中用来处理execl表格的库 参考

  3. 手机大数据_SQL映射对象_动软_代码模板_Models

    <#@ template language="c#" HostSpecific="True" #> <#@ output extension= ...

  4. XiaoShi657的留言板

    大家好,很荣幸能够借助此平台和大家分享.讨论编程技术! 有什么想对我说的请在这里留言吧

  5. iOS -Swift 3.0 -UIButton属性大全

    // //  ViewController.swift //  Swift-UIButton // //  Created by luorende on 16/9/9. //  Copyright © ...

  6. Aws api gateway Domain name

    Set Up a Custom Domain Name for an API Gateway API The following procedure describes how to set up a ...

  7. 使用IXmlSerializable的问题

    最近又开始使用XML了,但今天遇到一个折腾我一下午加一个晚上的时间,终于从网络上找到相关的资料解决了. 有一个成员是用来存放正则表达式的,由于里面包含其它字符,所以想用CDATA来保存方便查看,所以想 ...

  8. throw 语句

    我们也可以写代码来抛出异常,抛出异常的语句时throw,其格式如下: throw 异常类的对象名 用throw抛出异常,一般放在方法内部.一个程序可以有多个throw.throw语句执行时,其后面的代 ...

  9. HashedWheelTimer

    HashedWheelTimer 是根据 Hashed and Hierarchical Timing Wheels: Data Structuresfor the Efficient Impleme ...

  10. Leetcode: Word Pattern II

    Given a pattern and a string str, find if str follows the same pattern. Here follow means a full mat ...