Code for how many duplicates in an array.

Given an array of integers, count the number of duplicate array elements. Duplicate is defined as more than one identical elements. For example, in the array [1, 3, 3, 5, 5, 5], the two 3's are one duplicate and so are the three 5's. So, the number of duplicates is 2.

Please let me know the logics and code.

Comments (2)