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. 添加gogs服务后 web丢失样式问题

    暂时的解决办法

  2. 最新AndroidSDK安装教程

    很多人都有安卓sdk安装的疑问,现在我就将步骤详细的介绍,那就直接进入正题吧. 工具/原料   Android SDK 方法/步骤     下载最新的Android SDK 文件,到官网选择自己想要的 ...

  3. SQL Server中的SQL语句优化与效率问题

    很多人不知道SQL语句在SQL SERVER中是如何执行的,他们担心自己所写的SQL语句会被SQL SERVER误解.比如: select * from table1 where name='zhan ...

  4. java yum安装的环境变量设置

    如何(怎样)在CentOS 6.X 或 redhat 上使用安装JDK runtime environment (openjdk) ? CentOS 6.X 和 5.X 自带有OpenJDK runt ...

  5. Power-BI 仪表盘实现动态预警

    BI系统中仪表盘“序列”中的“预警”属性可以手工填入固定的值,也可从数据集里取值设定预警范围 ,以实现动态预警.其中的“范围”属性手工输入固定值应该为百分比(0-1),而在下拉选择绑定列为值是为数值. ...

  6. WebApi 找到了与该请求匹配的多个操作

    在同一个命名空间内,报错 错误的路由代码: namespace CRM4S { public static class WebApiConfig { public static void Regist ...

  7. less 初试

    第一次接触less,做些记录. 官网     民间中文文档      less notepad++插件 1. 支持变量声明 支持颜色.大小等相加 @nice-blue: #5B83AD; @light ...

  8. 理解v$sql的exact_matching_signature与force_matching_signature

    理解v$sql的exact_matching_signature与force_matching_signature 对SQL语句,去掉重复的空格(不包括字符常量),将大小写转换成相同,比如均为大写(不 ...

  9. c# Start/Stop/Check Status远程计算机的Windows Service

    static void Main(string[] args) { ConnectionOptions op = new ConnectionOptions(); // 登陆远程计算机的远程, op. ...

  10. c#两个数据库之间进行表拷贝