Leetcode 242 Valid Anagram pytyhon
题目:
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的更多相关文章
- 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验证变位词
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 (验证变位词)
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = &q ...
- [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 ...
- (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 ...
- 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, ...
- 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 = & ...
随机推荐
- SQL SERVER中如何格式化日期
1. SELECT convert(varchar, getdate(), 100) -- mon dd yyyy hh:mmAM (or PM) -- Oct 2 2008 11:01AM ...
- Bone Collector II(HDU 2639 DP)
Bone Collector II Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- mysql----二进制包安装
1.增加mysql用户 useradd mysql 2.解压mysql 二进制包到/usr/local/ -linux-glibc2.-x86_64.tar.gz -C/usr/local/ 3.创建 ...
- Discuz!X2.5论坛在IIS和Apache环境配置实现伪静态
最近在研究自己的网站,然后把这文章分享出来,让不清楚怎么设置的童鞋参考,高手可以飘过~~~ URL 静态化是一个有利于搜索引擎的设置,通过 URL 静态化,达到原来是动态的 PHP 页面转换为静态化的 ...
- android android:textColor="@[package:]color/filename" ----Color/filename文字颜色selector状态列表
文字颜色selector状态列表
- ArcEngine10在VS2010中编译问题
原文 http://www.gisall.com/html/47/122747-4141.html 问题描述: 前段时间装了个VS2010,用ArcEngine10在VS2010中基于.Net Fra ...
- Binary Tree Level Order Traversal II 解答
Question Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, ...
- C语言中指针的指针是如何工作的?
我们有时看到这样地饿代码: int *ptr = &x; 这里,ptr是一个指向x在内存中的地址的指针. 假设有另外一条语句是这样地的: int **ptr2 = &ptr; 我们 ...
- 360WIFI下使用Fiddler抓取手机APP流量
过程其实很简单,仅仅做个记录.过程适用Android和ios手机 fidder的原理如下: 下面开始步骤: 1.在fidder中设置代理:Tools--->Fidder Options,设置端口 ...
- UML图总结
UML叙述 UML文档仅仅是设计与开发人员采用UML语言进行系统分析与设计的结果,并没有给出如何进行开发和采用何种开发流程,同样也不指导如何进行面向对象设计. UML文档描述了面向对象分析与设计的结果 ...