# Cloudin 云英 面试题 defis_similar(A, B): dict_a = {} dict_b = {} for i in A: if i in dict_a: dict_a[i] += 1 else: dict_a[i] = 1 for j in B: if j in dict_b: dict_b[j] += 1 else: dict_b[j] = 1
if dict_a == dict_b: returnTrue else: returnFalse
if __name__ == "__main__": A = "aac" B = "caa" print(is_similar(A, B)) A = "aac" B = "caab" print(is_similar(A, B))