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 = & ...
随机推荐
- CentOS 6.4 LNMP 环境编译安装
1.关闭 SELinux 编辑 /etc/selinux/config SELINUX="disabled" 2.安装编译器 yum install gcc gcc-c++ -y ...
- 对于C++中const & T operator= 的一点思考
一个正常的assignment操作符的声明是这样的. const elmentType & elmentType::operator=(const elmentType &rhs) 这 ...
- JavaSctipr 兼容、技巧、牛角尖
关于JavaSctipt的兼容性,最懒的办法就是用jQuery的工具函数.尽量不要用那些什么ECMAScript之类的函数,因为很多浏览器都会报找不到函数的错误.下面列出一些在开发过程中碰到过的jav ...
- android sdk 如何重新生成debug.keystore
1)首先你要确定你安装的JDK位置,Windows->Preferences->Java->Installed JREs,你可以看到是Jre的location,再在dos cmd模式 ...
- POJ 2533 Longest Ordered Subsequence - from lanshui_Yang
题目大意:求一个数列的最长上升子序列(严格上升). 解题思路: 方法一:O(n^2) dp[i]:表示处理到第i个位置,序列的最长上升子序列末尾为i的长度: a[]数组存储原序列 dp[i] = ma ...
- java 防止sql注入的方法(非原创)
一.SQL注入简介 SQL注入是比较常见的网络攻击方式之一,它不是利用操作系统的BUG来实现攻击,而是针对程序员编程时的疏忽,通过SQL语句,实现无帐号登录,甚至篡改数据库. 二.SQ ...
- 百度地图LV1.5实践项目开发工具类bmap.util.jsV1.1
/** * 百度地图使用工具类-v1.5 * * @author boonya * @date 2013-7-7 * @address Chengdu,Sichuan,China * @email b ...
- 借贷宝注册送现金疯转 新闻PS图背后真相
动动手指,20元人民币立即到手:http://www.cnblogs.com/mfryf/p/4754384.html 近日,九鼎投资旗下投资平台借贷宝开展的“拉上好友抢红包,轻轻松松玩出钱”引起市场 ...
- Java如何访问Axis2服务端
import javax.xml.namespace.QName; import org.apache.axis2.AxisFault; import org.apache.axis2.address ...
- 在Linux下如何创建LVM及LVM创建过程
Linux LVM创建过程:(我用的是Centos6.8) 一.准备工作: LVM可以的创建可以在系统安装的过程中创建,也可以在安装完系统之后再创建建,都是可以的,我的是在系统安装完之后创建的,具体的 ...