[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 ...
随机推荐
- InnoDB存储引擎表的主键
在InnoDB存储引擎中,表是按照主键顺序组织存放的.在InnoDB存储引擎表中,每张表都有主键(primary key),如果在创建表时没有显式地定义主键,则InnoDB存储引擎会按如下方式选择或创 ...
- 3G 4G 5G中的网络安全问题——文献汇总
Modeling and Analysis of RRC-Based Signalling Storms in 3G Networks 还是使用状态机模型来做恶意UE识别 https://san.ee ...
- auxre7使用安装
auxre7安装 1● auxre7下载 2● 安装 D:\soft axureuser 8wFfIX7a8hHq6yAy6T8zCz5R0NBKeVxo9IKu+kgKh79FL6IyP ...
- Ubuntu上安装MySQL
Ubuntu上安装MySQL非常简单只需要几条命令就可以完成.`````` sudo apt-get update sudo apt-get install mysql-server 会弹出提示,让输 ...
- ueeditor 百度编译器使用onchange效果
<script id="editor" type="text/plain" style="width:100%;height:200px;&qu ...
- ubuntu16.10安装网易云音乐
首先去官网(https://music.163.com/#/download)下载安装包:netease-cloud-music_1.1.0_amd64_ubuntu.deb 下载好以后,执行安装命令 ...
- php 图片添加水印和二维码
$host = $_SERVER['HTTP_HOST']; $save_code_file = './qrcodes/qrcode.png'; QrCode::format()->backgr ...
- shell脚本分析二
Shell 基本运算符Shell 和其他编程语言一样,支持多种运算符,包括: 算数运算符 关系运算符 布尔运算符 字符串运算符 文件测试运算符原生bash不支持简单的数学运算,但是可以通过其他命令来实 ...
- js作用域及闭包
作用域 执行环境是js最为重要的一个概念.执行环境定义了变量或函数有权访问的其他数据,决定了它们各自的行为. 1.全局执行环境就是最外围的一个执行环境,每一个函数都有自己的作用域 2.简单的说局部作用 ...
- Java:将Excel数据导入到数据库(一眼就看会)
所用Jar包 1. sqljdbc4.jar 连接数据库的Jar包(根据数据库的不同进行选择,我用的SqlServer2008) 2.Jxl.jar 访问Excel的Jar包 注意:支持以.xls结尾 ...