Question: code javascript: Count the minimum number of integers that must be deleted from an array so that no two integers occur the same number of
code javascript:
Count the minimum number of integers that must be deleted from an array so that no two integers occur the same number of times.
Task description
An array A consisting of N integers is given. Our goal is to obtain an array in which every value occurs a unique number of times. We only consider integers that appear at least once in the resulting array. To achieve the goal, we can delete some integers from A What is the minimum number of integers that must be deleted from A so that every remaining value occurs a unique number of times?
Write a function:
function solutionA;
that, given an array A consisting of N integers, returns the minimum number of integers that must be deleted from it so that every remaining value occurs a unique number of times.
Examples:
Given A the function should return We can delete one occurrence of or one occurrence of After this operation, one value will occur three times and the other one two times.
Given A the function should return After deleting number twice, the remaining elements of the array are In this array no two numbers occur the same number of times.
Given A the function should return All elements of the array occur exactly once. We have to delete all but one element.
Given A the function should return
Write an efficient algorithm for the following assumptions:
N is an integer within the range ;
each element of array A is an integer within the range
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
