Solución
solution.tsTypeScript
def top_n_words(text: str, n: int) -> list[str]:
words = set(text.lower().split())
word_list = sorted([(w, text.lower().count(w)) for w in words], key=lambda x: (-x[1], x[0]))
return [word for word,_ in word_list[:n]]0respuestas