102. Count by Department
Core1000 ms256 MBSolved by 0%
Read n employee records, each holding a name and a department number.
Print how many employees are in each department, one per line, as
department count, in increasing order of department number.
Departments with nobody in them are not printed.
Constraints - `1 ≤ n ≤ 100000` - Names are 1 to 30 letters with no spaces. - `1 ≤ department ≤ 100`
Input
The first line contains an integer n.
Each of the next n lines contains a name and a department number.
Output
Print one line per department as department count, in increasing department order. Empty departments are not printed.
Input4
A 1
B 2
C 1
D 3
Output1 2
2 1
3 1
Notehas three departments in a scrambled order
Input3
A 5
B 5
C 5
Output5 3
Notehas everyone in one department
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.