Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 460 Bytes

77.md

File metadata and controls

23 lines (16 loc) · 460 Bytes
@author jackzhenguo
@desc 
@date 2019/4/19

77 异位词

两个字符串含有相同字母,但排序不同,简称:互为变位词

from collections import Counter

# 

def anagram(str1, str2):
    return Counter(str1) == Counter(str2)

anagram('eleven+two', 'twelve+one')  # True 这是一对神器的变位词
anagram('eleven', 'twelve')  # False
[上一个例子](76.md) [下一个例子](78.md)