题解 | #查找兄弟单词#
查找兄弟单词
http://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
import sys #判断是否兄弟单词 def checkXD(word, x): if len(w) != len(x) or w == x: return False if sorted(word) == sorted(x): return True return False while True: try: ss = input().split() n = int(ss[0]) words = ss[1: n + 1] x = ss[n + 1] k = int(ss[n + 2]) # print(n,words,x, k) xiwords = [] for w in words: if checkXD(w, x): xiwords.append(w) xiwords.sort() print(len(xiwords)) #如果越界,就不输出 if k <= len(xiwords): print(xiwords[k - 1]) except: # print(sys.exc_info()) break