[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 ...
随机推荐
- 记一次搭建vsftp服务器坑
避免踩坑,特此记录... yum -y install vsftpd useradd -d /www -s /sbin/nologin sui # 修改vsftpd配置文件/etc/vsftpd/vs ...
- 查看MySQL的线程
通过两张表查看MySQL的线程:information_schema.processlist 和 performance_schema.threads processlist是information_ ...
- WebSphere安装教程(WAS6.1为例)
1.网络准备 我们选择图形界面安装,如果堡垒机是windows则要在目标机器安装桌面环境并开启vcnserver:如果堡垒机是Linux则在堡垒机安装桌面环境和vncserver,然后将目标机的DIS ...
- Swagger 路径过滤 -PreSerializeFilters
Swagger 默认显示所有api, 如果要做路径过滤,可以这样做. //过滤,只显示部分api app.UseSwagger(c=> { c.PreSerializeFilters.Add(( ...
- oracle中计算两个日期的相差天数、月数、年数、小时数、分钟数、秒数等
oracle如何计算两个日期的相差天数.月数.年数.小时数.分钟数.秒数 1.相差天数(两个日期相减) --Oracle中两个日期相差天数-- select TO_NUMBER(TO_DATE('20 ...
- linux下/proc/diskstats文件详解
每一列的含义分别为: 第一列为 设备号 (number of issued reads. This is the total number of reads completed successfull ...
- js 小说格式整理
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name ...
- 笨办法06字符串(string)和文本
代码如下: # coding : utf-8 x = "There are %d types of people." % 10 binary = "binary" ...
- Docker的安装以及使用Docker安装jenkins,gogs,tomcat(一)
(1)Docker的安装 官网安装链接 :https://yeasy.gitbooks.io/docker_practice/content/ 卸载旧版本 旧版本的 Docker 称为 docker ...
- 2.15 C++常量指针this
参考: http://www.weixueyuan.net/view/6346.html 总结: 在每一个成员函数中都包含一个常量指针,我们称其为this指针,该指针指向调用本函数的对象,其值为该对象 ...