You are viewing a single comment's thread. Return to all comments →
def distinct(words: list[str]) -> None: counter: dict[str,int] = {} for word in words: if word in counter: counter[word] += 1 else: counter[word] = 1 print(len(counter)) for v in counter.values(): print(v, end=' ') if __name__ == "__main__": n = int(input()) words = [input() for i in range(n)] distinct(words)
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Word Order
You are viewing a single comment's thread. Return to all comments →