Count Repeated Values (Set 1)

Easy

Given an array of integers nums, return how many distinct values appear more than once.

Count Repeated Values (Set 1) — the data. This set runs 4 cases: nums holds arrays of 6–10 items, with values from 1 to 6. The hidden cases are the largest of the set.

Example 1

countDuplicatedValues()
Input
nums = [6, 3, 3, 4, 2, 4]
Output
2

Why

`countDuplicatedValues` returns `2` for this input.

Example 2

countDuplicatedValues()
Input
nums = [4, 6, 3, 4, 5, 5, 6, 5]
Output
3

Why

`countDuplicatedValues` returns `3` for this input.
Constraints
0 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

ArraysCounting

Implement countDuplicatedValues in the editor and return the answer — printing it is never graded.