Valid Anagram
- 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的更多相关文章
- 【09_242】Valid Anagram
Valid Anagram My Submissions Question Total Accepted: 43694 Total Submissions: 111615 Difficulty: Ea ...
- leetcode面试准备:Valid Anagram
leetcode面试准备:Valid Anagram 1 题目 Given two strings s and t, write a function to determine if t is an ...
- 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. ...
- 22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)
22. 242. Valid Anagram(由颠倒字母顺序而构成的字) Given two strings s and t, write a function to determine if t i ...
- 【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 ...
- [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: ...
- leetcdoe Valid Anagram
题目连接 https://leetcode.com/problems/valid-anagram/ Valid Anagram Description Given two strings s and ...
- 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 ...
- LeetCode_242. Valid Anagram
242. Valid Anagram Easy Given two strings s and t , write a function to determine if t is an anagram ...
- LeetCode 242. 有效的字母异位词(Valid Anagram)
242. 有效的字母异位词 LeetCode242. Valid Anagram 题目描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s ...
随机推荐
- iOS开发 - 网络数据安全加密(MD5)
提交用户的隐私数据 一定要使用POST请求提交用户的隐私数据GET请求的所有参数都直接暴露在URL中请求的URL一般会记录在服务器的访问日志中服务器的访问日志是黑客攻击的重点对象之一 用户的隐私数据登 ...
- leetcode 116- Populating Next Right Pointers in Each Node
题目: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode ...
- notpad++安装python插件
1.安装python并添加到环境变量 2.在notpad++ 运行工具下点击运行,输入如下命令: cmd /k python "$(FULL_CURRENT_PATH)" & ...
- linux_x86_64 blat安装
blatSrc35.zip下载地址:http://users.soe.ucsc.edu/~kent/src/ 对于下载好的源代码安装包blatSrc35.zip,需进行编译,安装过程如下: 1.用un ...
- Java 类型转换以及Object转成其他类型
Object转int int count=(int)map.get("count") int count=Integer.parseInt((String)map.get(&quo ...
- The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. 怎么解决
cd 文件 pod install --no-repo-update 就可以了
- 解决Ueditor 不兼容IE7 和IE8
引用Ueditor的js 的时候用 绝对路径
- PostgreSQL/bin
pg_receivexlog pg_receivexlog—以流的方式从一个PostgreSQL集簇得到事务日志 pg_receivexlog被用来从一个运行着的PostgreSQL集簇以流的方式得到 ...
- Leetcode: Mini Parser
Given a nested list of integers represented as a string, implement a parser to deserialize it. Each ...
- java类的定义以及参数传递
class类(类似结构体)的定义 import java.util.Scanner; import java.io.*; class student{//类的名称 public String name ...