
You are given a list of N integers. Your task is to count the frequency of each unique number in the list.
You must then print the unique numbers and their corresponding frequencies, sorted in ascending order by the number.
The first line of input contains an integer 'N', the number of elements in the list.
The second line contains 'N' space-separated integers, representing the list of numbers.
For each unique number found in the list, print a new line in the format: number->frequency
The lines must be sorted in ascending order based on the number.
The numbers can be positive, negative, or zero.
8
2 4 2 8 4 4 2 9
2->3
4->3
8->1
9->1
The frequencies of the numbers are:
2 appears 3 times.
4 appears 3 times.
8 appears 1 time.
9 appears 1 time.
The output is printed in ascending order of the numbers (2, 4, 8, 9).
5
10 20 30 40 50
10->1
20->1
30->1
40->1
50->1
All numbers in the list are unique, so each has a frequency of 1.
The expected time complexity is O(N log K) or O(N), where N is the number of elements and K is the number of unique elements.
1 <= N <= 10^5
-10^9 <= number <= 10^9
Time limit: 1 sec