Counting Sort

5

3 votes
Very-Easy
Problem

You have been given an integer array A of size N. Each element of the array ranges between 1 and 105. You need to find the frequency of each distinct element of the array. The elements need to be present in the output in ascending order. You need to print the value and then frequency of each distinct element.

Input Format:

The first line contains a single integer N denoting the size of the array. The next line contains N space separated integers, denoting the elements of the array.

Output Format

For each distinct integer, print its value and then frequency in a new line. The distinct integers should appear in the output in ascending order.

Constraints

1N100

1A[i]100

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?