题解 | 查找兄弟单词
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
def is_anagram(s1,s2): return sorted(s1) == sorted(s2) def find_brother_words(words,x,k): brother_words = [] for word in words: if word != x and is_anagram(word,x): brother_words.append(word) brother_words.sort() print(len(brother_words)) if k <= len(brother_words): print(brother_words[k-1]) lines = input().strip().split() n = int(lines[0]) words = lines[1:n+1] x = lines[n+1] k = int(lines[n+2]) find_brother_words(words, x, k)#华为od#