Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 389 Bytes

File metadata and controls

21 lines (15 loc) · 389 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