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++)的更多相关文章

  1. 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 = & ...

  2. 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 ...

  3. 22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)

    22. 242. Valid Anagram(由颠倒字母顺序而构成的字) Given two strings s and t, write a function to determine if t i ...

  4. 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 ...

  5. 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 = & ...

  6. 【一天一道LeetCode】#242. Valid Anagram

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Given t ...

  7. 【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 ...

  8. [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: ...

  9. LeetCode:36. Valid Sudoku(Medium)

    1. 原题链接 https://leetcode.com/problems/valid-sudoku/description/ 2. 题目要求 给定一个 9✖️9 的数独,判断该数独是否合法 数独用字 ...

随机推荐

  1. NodeJS with Express 4.x

    Express 4.x 静态资源目录设置: //静态文件目录 app.use('/public', express.static(__dirname+'/public')); app.use('/da ...

  2. Eclipse常用插件推荐

    Eclipse Web Tools Platform(WTP) 地址:http://download.eclipse.org/webtools/ WTP十分强大,支持HTML, JavaScript, ...

  3. 让IE6兼容position:fixed

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. N对括号的合法组合

    递归实现,需要注意以下几点: 1. 递归终止条件 2. 递归递推关系式 这里实际上是一个排列问题,只是排列需要满足条件在每一次递归调用时左括号数不能少于右括号数. 还有一点需要特别注意,当推出递归调用 ...

  5. Javascript数据类型——number类型

            ECMAScript规范中使用IEEE754格式来表示整数和浮点数.支持十进制.八进制以及十六进制.有一点注意的是八进制数字在严格模式下是无效的,这可能会影响到程序的正常运行. 避免浮 ...

  6. Oracle中分页查询语句

    Oracle分页查询语句使我们最常用的语句之一,下面就为您介绍的Oracle分页查询语句的用法,如果您对此方面感兴趣的话,不妨一看. Oracle分页查询语句基本上可以按照本文给出的格式来进行套用.O ...

  7. php 链接access数据库

    php链接access数据库代码 <?php $odbc = "Driver={Microsoft Access Driver (*.mdb)};Dbq=".realpath ...

  8. 基于iOS,Android的服务器证书失效检测

    1.前言 在目前的iOS,Android手机上,当手机应用进行SSL通信时,手机端默认是不会进行服务器证书是否失效的监测. 在iOS上,系统是会定期获取所访问服务器的证书信息然后出存在本地. 在And ...

  9. postgresql9.4新特性jsonb学习-update更新操作

    先科普下概念:PgSQL9.4 新增 JSONB 数据类型, JSONB 同时属于 JSON (JavaScript Object Notation) 数据类型,jsonb 和 json 的输入数据几 ...

  10. Python中的判断、循环 if...else,while

    if...else语句: a=3; b=3; if a == b :print(a,b)elif a <= b :print(str(a) + " is less than " ...