题解 | #查找兄弟单词#
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
def isBrother(x: str, y: str): if len(x) == len(y): if x != y: ls_y = [yy for yy in y] for xx in x: for i in range(len(ls_y)): if xx == ls_y[i]: del ls_y[i] break if len(ls_y) == 0: return True return False s = input().split() dic = s[1:-2] x = s[-2] k = int(s[-1]) num = 0 brother = [] for word in dic: if isBrother(word, x): num += 1 brother.append(word) brother.sort() print(num) if k <= num: print(brother[k - 1])