242. Valid Anagram Add to List
Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.
Note:
You may assume the string contains only lowercase alphabets.
//排个序比较一下
//或者用数组记录每个单词出现的次数
//在这我用的是第一种方法,比较快。
class Solution {
public:
bool isAnagram(string s, string t) {
if(s.size()!=t.size())
return false;
else{
sort(s.begin(),s.end());
sort(t.begin(),t.end());
if(s==t)
return true;
else
return false;
} }
};
242. Valid Anagram Add to List的更多相关文章
- 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 ...
- 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 (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: ...
- LeetCode 242 Valid Anagram
Problem: Given two strings s and t, write a function to determine if t is an anagram of s. For examp ...
- 【leetcode❤python】242. Valid Anagram
class Solution(object): def isAnagram(self, s, t): if sorted(list(s.lower()))==sorted(list ...
- 242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = &q ...
- (easy)LeetCode 242.Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = &q ...
随机推荐
- 使用ajax进行汽车详情表的查询
主界面代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...
- 深度学习1--ubuntu14.04+win10双系统
相当多的内容参考的百度经验https://jingyan.baidu.com/article/eb9f7b6d79a7b4869364e885.html?qq-pf-to=pcqq.group 还可以 ...
- formatblock 块及
有标签,执行标签替换,只是替换标签,属性不改变. 在无标签外部添加标签
- $百度应用引擎BAE的使用与应用部署
百度应用引擎(BAE)是百度推出的网络应用开发平台,开发者使用BAE不需要进行服务器的配置.维护等繁琐的工作,也不需要进行域名的申请.备案等工作,而只需要上传自己的WEB应用即可在公网上访问.使用及部 ...
- npm安装出错Unexpected end of input at 1:2307
执行命令: npm cache clean --force 然后再安装 搞定
- 数据库自动增长id下一次的值
mysql SELECT auto_increment FROM information_schema.`TABLES` WHERE TABLE_SCHEMA='my_db_name' AND TAB ...
- Linux bridge
CentOS bridge 配置: 1.创建br0配置文件 touch /etc/sysconfig/network-scripts/ifcfg-br0 2.修改bro配置文件 vi /etc/sy ...
- mysql一次运行多个SQL文件
在文件 batch.sql 中写下多个SQL文件 source file1.SQLsource file2.SQLsource file3.SQL 然后运行 source batch.sql
- R语言学习笔记(1)
第一章:R语言介绍 一 R的使用 1 R是一种区分大小写的解释型语言.R语句由函数和赋值构成.R使用<-作为赋值符号.例如: x<-rnorm(5) 创建了一个名为x的向量对象,它包含5个 ...
- 爬虫之MongoDB的图片
聚合: