Given an array of integers, determine the minimum number of elements to delete to leave only elements of equal value.
Delete the elements and leaving . If both twos plus either the or the are deleted, it takes deletions to leave either or . The minimum number of deletions is .
Complete the equalizeArray function in the editor below.
equalizeArray has the following parameter(s):
- int arr[n]: an array of integers
- int: the minimum number of deletions required
The first line contains an integer , the number of elements in .
The next line contains space-separated integers .
STDIN Function ----- -------- 5 arr size n = 5 3 3 2 1 3 arr = [3, 3, 2, 1, 3]
Delete and to leave . This is minimal. The only other options are to delete elements to get an array of either or .