Frequency Map
Easyjavapythonccppjavascript
Given an integer array, count how many times each distinct value occurs and report the counts in order of the values' first appearance.
Input Format
The first line contains an integer N. The second line contains N space-separated integers.
Output Format
For each distinct value, in order of first appearance, print a line v = k where v is the value and k is its count.
Example 1
Input
6 2 3 2 5 3 2
Output
2 = 3 3 = 2 5 = 1
Explanation: 2 appears 3 times, 3 twice, 5 once — listed in first-appearance order.
- 1 <= N <= 100000
- -1000000000 <= A[i] <= 1000000000
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Find Duplicate ValuesEasy · java, python, c, cpp, javascriptSolve Problem
- Common Elements in Three ArraysEasy · java, python, c, cpp, javascriptSolve Problem
- Pair with Given DifferenceEasy · java, python, c, cpp, javascriptSolve Problem