题解 | 查找兄弟单词
def is_brother(s, target):
if len(s) != len(target) or s == target:
return False
return sorted(s) == sorted(target)
n, *words, x, k = input().split()
n = int(n)
k = int(k)
brother_words = []
for s in words:
if is_brother(s, x):
brother_words.append(s)
print(len(brother_words))
if k <= len(brother_words):
print(sorted(brother_words)[k-1])
查看1道真题和解析