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. QT中静态库的生成与使用

    一. 静态库的生成    1. 测试目录: lib    2. 源码文件名: mywindow.h, mywindow.cpp, 类MyWindow继承于QPushButton, 并将文字设置为&qu ...

  2. [BS-23] AFN网络请求上拉/下拉刷新的细节问题总结

    上拉/下拉刷新的细节问题总结 1.如果导航栏有透明色,则也需要设置header自动改变透明度 self.tableView.mj_header.automaticallyChangeAlpha = Y ...

  3. [BS-04] 在iOS中对系统定义的类的readonly属性可通过KVC进行赋值

    系统提供的类的readonly属性可通过KVC进行赋值 UITabBarController.h @interface UITabBarController : UIViewController &l ...

  4. 第六篇 SQL Server安全执行上下文和代码签名

    本篇文章是SQL Server安全系列的第六篇,详细内容请参考原文. SQL Server决定主体是否有必要的执行代码权限的根本途径是其执行上下文规则.这一切都可能复杂一个主体有执行代码的权限,但是却 ...

  5. 注册页面的简单搭建(H5)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. snapshot standby database

    快照备库接收和归档主库发送来的redo,但是不会应用:切换成physical standby之后会自动开启redo apply.快照standby不可以参加主备切换:在最大保护性模式下,如果只有一个备 ...

  7. linux:网络yum源和制作本地光盘yum源

    linux:存放yum源的位置:/etc/yum.repos.d/,该目录下全是一些yum源 一.网络yum源: 如图:下面全部都是yum源,后缀是".repo"都是合法的yum源 ...

  8. 数据库 CRUD

    1.删除表 drop  table +表名 2.修改表 alter  table+表名+ add(添加)+列名+ int(类型) alter  table+表名+ drop(删除)+column(列) ...

  9. 。。。Spring框架总结(一)。。。

    Spring框架已经学习了两遍了,第一遍基本上忘得差不多了,现在开始复习第二遍的,也复习的差不多了,比之前懂了很多东西,今天就写下来,记录一下我滴小成果! 首先,在Spring框架中有两个重要的概念: ...

  10. MySQL 中NULL和空值的区别 (转载 http://blog.sina.com.cn/s/blog_3f2a82610102v4dn.html)

    平时我们在使用MySQL的时候,对于MySQL中的NULL值和空值区别不能很好的理解.注意到NULL值是未知的,且占用空间,不走索引,DBA建议建表的时候最好设置字段是NOT NULL 来避免这种低效 ...