Skip to content

Latest commit

 

History

History

word-order

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Word Order

https://www.hackerrank.com/challenges/word-order

Problem

You are given N words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.

Note: Each input line ends with a "\n" character.

Input Format

The first line contains the integer, N.
The next N lines each contain a word.

Output Format

Output 2 lines.
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.

Sample Input 0

4
bcdef
abcdefg
bcde
bcdef

Sample Output 0

3
2 1 1

My Solution