题目:

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.

用到了python的sorted函数,原型:sorted(data, cmp=None, key=None, reverse=False)

将一个字符串当做是参数返回一个排好序的序列,不会改变字符串的值。

 class Solution(object):
def isAnagram(self, s, t):
return sorted(s) == sorted(t)

Leetcode 242 Valid Anagram pytyhon的更多相关文章

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

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

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

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

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

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

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

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

  8. Java [Leetcode 242]Valid Anagram

    题目描述: Given two strings s and t, write a function to determine if t is an anagram of s. For example, ...

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

随机推荐

  1. 【HTML5】在head 设置 meta 能更方便开发

    <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initi ...

  2. vim 常用快捷键 二[转]

    键盘移动 (Move) 一切都从键盘的移动k -> 上 upj -> 下 downh -> 左 leftl -> 右 rightz -> 重画屏幕,当前光标变成屏幕的第一 ...

  3. php 写队列

    这里不得不提到php的数组函数真的是太强大了 队列是先进先出 那么对于数组来说就尾部插入,头部拿出 这里提供方法 尾部插入 我们知道有一个函数array_push 头部拿出 array_shift($ ...

  4. iscsi模型相关点

    1.iscsi即ip scsi,按架构分为控制器架构.链接桥系统架构.pc系统架构.这里主要说明一下pc系统架构. 所谓的pc系统架构,就是利用target软件存储端+initiator客户端+tcp ...

  5. python Post方式发起http请求 使用百度接口地理编码

    import os import httplib import json import urllib baiduapi="api.map.baidu.com:80" src=&qu ...

  6. IoC - Castle Windsor 2.1

    找过一些Windsor教程的文章,博客园上TerryLee有写了不少,以及codeproject等也有一些例子,但都讲的不太明了.今天看到Alex Henderson写的一个系列,非常简单明了.下面是 ...

  7. Windows7里的“计算器”你真的会用吗?

    “计算器”是不同Windows版本中的必备工具,虽然功能单一,但的确是人们日常工作中不可缺少的辅助工具,本文就来谈谈它的使用. 一.标准型和科学型两种面板 我们既可从Windows附件菜单中启动它,也 ...

  8. WebSocket 简介

    在HTML5规范中,我最喜欢的Web技术就是正迅速变得流行的WebSocket API.WebSocket提供了一个受欢迎的技术,以替代我们过去几年一直在用的Ajax技术.这个新的API提供了一个方法 ...

  9. Android中通过代码获取arrays.xml文件中的数据

    android工程res/valuse文件夹下的arrays.xml文件中用于放各种数组数据,比如字符串数组.整型数组等,数组中的数据可能是具体的值,也有可能是对资源数据的引用,下面针对这两种情况通过 ...

  10. arm linux中添加开机启动

    微处理器:S5PV210操作系统:linux3.0.8 前言:    在产品中,基本上都要屏蔽arm开发板中linux系统的对外通信,只应该通过产品的相关APP做相关操作.    因此需要把该APP添 ...