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 ...
随机推荐
- mysql分组查询
有一张学生选课表 Table: Subject_Selection Subject Semester Attendee --------------------------------- ITB001 ...
- css小知识---input输入块
对于如下的界面,介绍一种实现方式. 可以将整个界面分为三块,左中右.通过display: inline-block;和float: right;左右浮动效果实现. 代码如下: <!DOCTYPE ...
- 开发自己的composer package
参考:https://laravel-china.org/articles/6652/learn-to-develop-their-own-composer-package-and-to-use-pa ...
- 大数据架构之:Spark
Spark是UC Berkeley AMP 实验室基于map reduce算法实现的分布式计算框架,输出和结果保存在内存中,不需要频繁读写HDFS,数据处理效率更高Spark适用于近线或准实时.数据挖 ...
- Jfreechart 生成不同数据源多个饼图(Multiple Pie Chart)
http://blog.163.com/ppy2790@126/blog/static/103242241201210130736274/ 项目中要用JfreeChart实现不同数据源多个饼图展现每个 ...
- verilog中一些基本的门电路如pmos和nmos等
最近在分析波形的时候,发现某个PAD模型的行为与想象的不一致,就进入stdcell里面看了下,主要是pmos和nmos相关的东西,暂列如下: 开关级基元14种 是实际的MOS关的抽象表示,分电阻型(前 ...
- 20145231第二周Java学习笔记
20145231 <Java程序设计>第2周学习总结 教材学习内容总结 本周的学习采用的依然是先看课本,再看视频,然后实践敲代码,最后根据学习笔记总结完成博客. 第三章:基础语法 知识点比 ...
- 写时拷贝(Copy On Write)方案详解
本文旨在通过对 写时拷贝 的四个方案(Copy On Write)分析,让大家明白写时拷贝的实现及原理. 关于浅拷贝与深拷贝,我在之前的博客中已经阐述过了 浅拷贝容易出现指针悬挂的问题,深拷贝效率低 ...
- 对正交频分复用OFDM系统的理解
OFDM系统 正交频分复用OFDM(Orthogonal Frenquency Division Multiplexing)是一种多载波调制技术. 基本思想:在发送端,它将高速串行数据经过串并变换形成 ...
- INSPIRED启示录 读书笔记 - 第28章 创业型公司的产品管理
产品设计方式 第一步:创业初期只设三个职位,产品经理.交互设计师和原型开发人员(职位可以兼任) 第二步:快速展开产品设计(高保真原型),邀请真实的目标用户验证产品原型,迭代修改 第三步:随着迭代的深入 ...