题解 | #查找兄弟单词#
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
while True: try: num_and_words = input().split() num = int(num_and_words[0]) words = num_and_words[1:len(num_and_words)-2] x = num_and_words[-2] k = int(num_and_words[-1]) new_x = list(x) new_dic = {} for i in x: if i not in new_dic: new_dic[i] = 1 else: new_dic[i] += 1 new_list = [] for i in range(len(words)): new_dic1 = {} for j in words[i]: if j in new_dic1: new_dic1[j] += 1 else: new_dic1[j] = 1 if new_dic1 == new_dic and words[i] != x: new_list.append(words[i]) else: continue sorted_new_list = sorted(new_list, key = str.upper) print(len(new_list)) print(sorted_new_list[k-1]) except: break