We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Collections
- Word Order
- Discussions
Word Order
Word Order
Sort by
recency
|
1633 Discussions
|
Please Login in order to post a comment
from collections import Counter N = int(input()) D = [] for i in range(N): D.append(input()) print(len(set(D))) print(*Counter(D).values())
from collections import Counter n =int(input()) li=[]
for i in range(n): word=input() li.append(word)
count_words=len(set(li)) print(count_words)
counts = Counter(li)
for count in counts.values(): print(count,end=" ")
n = int(input())
dic = {}
for _ in range(n): word = input() if word in dic.keys(): dic[word]+=1 else: dic[word] = 1
print(len(dic.keys()))
occ = [str(i) for i in dic.values()]
print(' '.join(occ))
Here is HackerRank Word Order in python solution - https://programmingoneonone.com/hackerrank-word-order-problem-solution-in-python.html