LeetCode 有效的字母异位词 Valid Anagram
发布日期:2021-07-14 01:03:41 浏览次数:42 分类:技术文章

本文共 592 字,大约阅读时间需要 1 分钟。

Given two strings s and t , write a function to determine if t is an anagram of s.

Example 1:

1 2
Input: s = "anagram", t = "nagaram" Output: true

Example 2:

1 2
Input: s = "rat", t = "car" Output: false

Note:

You may assume the string contains only lowercase alphabets.

Follow up:

What if the inputs contain unicode characters? How would you adapt your solution to such case?

PYTHON3:

解法:先进行排序,然后判断字符串是否相同

1 2 3 4 5 6 7 8
class Solution:     def isAnagram(self, s, t):         """         :type s: str         :type t: str         :rtype: bool         """         return sorted(s)==sorted(t)

转载地址:https://blog.csdn.net/cpongo3/article/details/89332109 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:网站开启CDN加速
下一篇:Wordpress添加共享许可协议

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月06日 01时34分15秒