Question
Consider an array of n integers, numbers. We define a non-unique value of numbers to be an integer that appears at least twice in the
Consider an array of n integers, numbers. We define a non-unique value of numbers to be an integer that appears at least twice in the array. For example, if numbers = [1, 1, 2, 2, 2, 3, 4, 3, 9], then there are a total of 3 non-unique values in the array (i.e., 1, 2, and 3).
Complete the countDuplicates function. It has 1 parameter: an array of integers, numbers. It must return an integer denoting the number of non-unique values in the numbers array.
Input The first line contains an integer, n, denoting the size of the numbers array. Each line i of the n subsequent lines (where 0 i < n) contains an integer describing the value of numbers[i]. Constraints 1 n 1000 1 numbers[i] 1000
Output The function must return an integer denoting the number of non-unique values in numbers. This is printed to stdout by locked stub code in the editor. in Python3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started