[LeetCode&Python] Problem 242. Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s.
Example 1:
Input: s = "anagram", t = "nagaram"
Output: true
Example 2:
Input: s = "rat", t = "car"
Output: false
Note:
You may assume the string contains only lowercase alphabets.
from collections import Counter
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if len(s)!=len(t):
return False
s1=Counter(s)
t1=Counter(t) for i in s1:
if s1[i]!=t1[i]:
return False
return True
[LeetCode&Python] Problem 242. Valid Anagram的更多相关文章
- 【leetcode❤python】242. Valid Anagram
class Solution(object): def isAnagram(self, s, t): if sorted(list(s.lower()))==sorted(list ...
- 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(C++)
242. Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. ...
- 【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】242. Valid Anagram 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 字典统计词频 排序 日期 [LeetCode] 题目地址:ht ...
- [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 ...
随机推荐
- 牛客网 PAT 算法历年真题 1011 : 个位数统计 (15)
个位数统计 (15) 时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 给定一个k位整数N = dk-1*10k- ...
- SPA单页面应用
什么是单页应用 单页Web应用,就是只有一张Web页面的应用.浏览器一开始会加载必需的HTML.CSS和JavaScript,之后所有的操作都在这张页面完成,这一切都由JavaScript来控制.因此 ...
- Oracle 当前日期如何添加指定年数、月数、天数、时数、分钟数、秒数
Oracle 当前时间如何添加指定数,来获取指定的年数.月份或其他的时间日期 --当前时间(2018-10-19 16:51:22)--- select sysdate nowDate from du ...
- oracle中如何创建表的自增ID(通过序列)
1.什么是序列呢? 序列是一数据库对象,利用它可生成唯一的整数.一般使用序列自动地生成主码值.一个序列的值是由特别的Oracle程序自动生成,因而序列避免了在运用层实现序列而引起的性能瓶颈. Orac ...
- Android--Android Studio 打开ADM报错
Android studio无法打开类似与eclipse的DDMS, 在android studio里点击android device monitor(点击菜单栏里的Tools->Android ...
- js之close()方法
.close()方法只适用于通过window.open()打开的弹出窗口.对于浏览器的主窗口,如果没有得到用户允许是不能关闭的.不过,弹出窗口可以调用top.close()在不经用户允许的情况下关闭自 ...
- 【Insert】使用java对mysql数据库进行插入操作
//插入100条数据package database; import java.sql.Connection; import java.sql.DriverManager; import java.s ...
- Win10系列:VC++ Direct3D模板介绍1
Visual Studio为开发Direct3D应用程序提供了便捷的模版,读者可以不必手动去新建Direct3D中所使用到的基础资源,而只需专注于图形的绘制.本小节主要为读者介绍这个模版中用于绘制图形 ...
- 北邮新生排位赛2解题报告a-c
A. 丁神去谷歌 2014新生暑假个人排位赛02 时间限制 1000 ms 内存限制 65536 KB 题目描述 丁神要去Google上班了,去之前丁神想再做一道水题,但时间不多了,所以他希望题目做起 ...
- Python Django 之 直接执行自定义SQL语句(一)
一.执行自定义SQL方法 1.Executing custom SQL directly 直接执行自定义SQL,这种方式可以完全避免数据模型,而是直接执行原始的SQL语句. 2.Manage ...