题目
abcd和dabc是同字母异序词
思路
通用语言解法,用Acsll长度的数组来统计每个字符的次数
def same_char_sort(list1,list2):
char_num = 256
count1 = [0]*char_num
count2 = [0]*char_num
for i in list1:
count1[ord(i)] += 1
for j in list2:
count2[ord(j)] += 1
if len(list1)!=len(list2):
return False
for i in range(char_num):
if count1[i]!=count2[i]:
return False
return True
s1 = "listen"
s2 = "silent"
a = same_char_sort(s1, s2)
print(a)