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.
For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.
题目大意:
判断两字符串含有的元素是否相同。
解题方法:
对字符串进行排序,在判断两字符串是否相等。
注意事项:
C++代码:
class Solution {
public:
bool isAnagram(string s, string t) {
sort(s.begin(),s.end());
sort(t.begin(),t.end());
return s==t;
}
};
242. Valid Anagram(C++)的更多相关文章
- 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 = & ...
- 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 ...
- 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 ...
- 242. Valid Anagram(leetcode)
Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = & ...
- 【一天一道LeetCode】#242. Valid Anagram
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given 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:36. Valid Sudoku(Medium)
1. 原题链接 https://leetcode.com/problems/valid-sudoku/description/ 2. 题目要求 给定一个 9✖️9 的数独,判断该数独是否合法 数独用字 ...
随机推荐
- jQuery技术内幕预览版.pdf3
jQuery.fn.init(selector,context,rootjQuery):构造函数 jQuery.fn.init() 负责解析参数 selector 和 context 的类型,并执行相 ...
- JavaScript高级程序设计24.pdf
Element类型 Element类型用于表现XML或HTML元素,提供对元素标签名.子节点及特性的访问,它具有以下特征 nodeType的值为1: nodeName的值为元素的标签名: nodeVa ...
- 解决 VirtualBox 安装windows 8.1 Preview OR Server 2012 R2 Preview 错误
安装windows 8.1 Preview 或 Server 2012 R2 Preview时提示错误 Your PC needs to restart 解决方法: 在cmd中输入以下代码执行即可: ...
- fopen/fclose
在操作文件之前要用fopen打开文件,操作完毕要用fclose关闭文件; 打开文件就是在操作系统中分配一些资源用于保存该文件的状态信息,并得到该文件的标示,以后用户程序就可以这个标志对文件做各种操作了 ...
- Shell while循环
while循环用于不断执行一系列命令,也用于从输入文件中读取数据:命令通常为测试条件.其格式为: while command do Statement(s) to be executed if com ...
- 用bat文件将本地sql在远程oracle上执行
最近在在搭建一个数据库的测试环境,需要初始化一些数据库脚本.因为内容比较多,分为很多个sql文件.现准备写一个bat文件,经过百度一番,终于搞定.如下: 1. 新建一个文件夹,将初始化的脚本文件全部放 ...
- iOS UITextField 输入字数限制的实现
首先你的ViewController需要实现 UITextFieldDelegate 代理, 其次,需要字数限制的UITextField实例的代理要设置成 self(ViewController) 然 ...
- 【转】[Android编程心得] Camera(OpenCV)自动对焦和触摸对焦的实现
参考http://stackoverflow.com/questions/18460647/android-setfocusarea-and-auto-focus http://blog.csdn.n ...
- LabVIEW系列——错误簇的传递
从以下示例可以得出结论: 1.图一出现的三种错误,分别位于打开/创建/替换文件函数,写入文本文件函数,读取文件文件函数.说明三个函数都被运行了. 2.图二只出现了一种错误,位于打开/创建/替换文件函数 ...
- Eclipse Key Shortcuts for Greater Developers Productivity--reference
Posted by Ajitesh Kumar / In Java / June 6, 2014 http://vitalflux.com/eclipse-key-shortcuts-greater- ...