Minimum Distinct Ids

easy
1. You are given an array of N elements. 2. Each of the array denote an id. There could be duplicate ids present in the array. 3. You are also given a number M. 4. You have to remove M elements of the array such that the distinct ids left in the array are minimum. 5. For example, Input : arr[] = { 2, 4, 1, 5, 3, 5, 1, 3} M = 2 Output : 3 Remove 2 and 4. So, remaining ids are 1, 3 and 5 i.e. 3 is the output. 5. display is a utility function, feel free to use it for debugging purposes. 6. main takes input from the users and creates the array. 7. This is a functional problem. 8. You have to complete the solve function. It takes as input an array, N and M. It should return the minimum number of distinct ids left in the array after removing M elements. 9. Don't change the code of main and display.

Input Format

First line takes input N, the length of the array. Second line takes input N space separated numbers representing the elements of the array. Third line takes input M. Input is handled for you.

Output Format

The minimum number of distinct ids left in the array after removing M elements. Output is handled for you.

Constraints

1 <= N <= 30000

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
8 
2 4 1 5 3 5 1 3
2
Output
3
Previous
Sort The String In Descending Order
Next
Sort String

Related Questions