(self, s1, s2)
| 50 | # 比较两个set, 如果不相等直接返回false |
| 51 | # 如果两个set相等, 比较每个set中字符在相应list中的个数, 个数不同返回false |
| 52 | def anagramSolution3(self, s1, s2): |
| 53 | alist1 = list(s1) |
| 54 | alist2 = list(s2) |
| 55 | |
| 56 | aset1 = set(alist1) |
| 57 | aset2 = set(alist2) |
| 58 | |
| 59 | if aset1 != aset2: |
| 60 | return False |
| 61 | else: |
| 62 | for ch in aset1: |
| 63 | if alist1.count(ch) != alist2.count(ch): |
| 64 | return False |
| 65 | return True |
| 66 | |
| 67 | s1 = 'abcde' |
| 68 | s2 = 'acbde' |