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
|
1622 Discussions
|
Please Login in order to post a comment
Tried this but it is too slow, it failed two tests due to timeout. Any suggestions on what is the bottleneck and how to speed it up?
print(len(word_list)) print(' '.join(map(str, occurrence_list)))
from collections import Counter
n = int(input()) cnt = Counter()
for _ in range(n): cnt[input()] += 1
print(len(cnt)) print(*[cnt[i] for i in cnt])