82. How Many Times Each? (Frequency Count)

Acceptance — 0 accepted 0 submissions

Easy
ArraysHashing
No companies listed
A juice shop recorded the flavour number of every glass sold today. The owner wants to know how many glasses of each flavour were sold.

Print each distinct value with its count, in the order the values first appeared.

Input Format
The first line has n.
The second line has n integers.

Output Format
For each distinct value (in first-appearance order), print a line: <value> <count>

Constraints
• 1 ≤ n ≤ 1000
• 1 ≤ value ≤ 10^9

Example 1

Input
7
3 1 3 2 1 3 5
Output
3 3
1 2
2 1
5 1

Explanation Flavour 3 sold 3 times, 1 twice, 2 once and 5 once.

Example 2

Input
3
8 8 8
Output
8 3

Explanation Only one flavour.

Example 3

Input
4
4 3 2 1
Output
4 1
3 1
2 1
1 1

Explanation All different, each sold once.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
3 3 1 2 2 1 5 1
No results yet
Run your code to test it against the sample cases.
Problem List