All problems

Museum Exit Tally

Medium · array

A museum hands out n numbered badges, numbered 1 to n, to its visitors. At the exit, a reader records the number of every badge that passes through. The result is the list badges with exactly n entries, but the reader is flaky: some badges were recorded several times and some not at all, so every entry is a number between 1 and n and the numbers can repeat.

Return a report of the badges that were recorded more than once. Each line of the report is [badge, times]: the badge number and how many times it appears in badges. List the lines in increasing order of badge number. If no badge repeats, return an empty list.

Examples

Example 1

Input: badges = [3, 1, 3, 3, 2, 2]

Output: [[2, 2], [3, 3]]

Badge 1 appears once, badge 2 twice and badge 3 three times.

Example 2

Input: badges = [1, 2, 3]

Output: []

Example 3

Input: badges = [2, 2, 2, 2]

Output: [[2, 4]]

Only badge 2 was ever recorded, and four times.

Constraints