How to solve this word order?

Issue

This Content is from Stack Overflow. Question asked by carbon_sailor

Sample Input:

4
bcdef
abcdefg
bcde
bcdef

Sample Output:

3
2 1 1

Explanation:
On the first line, output the number of distinct words from the input.
On the second line, output the number of occurrences for each distinct word according to their appearance in the input.



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?