Marks :100
: 5 | : 2
Shweta is a college girl and she loves candies she wants to share some candies with her friend Radhika. She is having N candies such that the ith candy is of A[i] brand were ($$$0 \le i \le N$$$). Lets us call this array the brand array. She wants to share the K candies with Radhika Such that the K-sized subsequence of the candies has a minimum number of distinct brands among all the possible subsequences of the length K.
Formally you will have to help Shweta in determining the subsequence of length K in the given array which has the minimum number of distinct brands among all possible subsequences of length K.
You will have to print the total brands of candies Radhika received.
The First line of input contains two integers N and K the number of candies Shweta has and the number of candies that she wants to give to her friend Radhika. ($$$1 \le K \le N \le 10^5$$$).
The next line contains N-spaced integers that each A[i] represents the brand of ith candy ($$$1 \le A_i \le 10^8$$$).
For each test case print, a single integer of the number of candies Radhika will receive
10 6 1 3 2 4 3 4 5 3 4 3
2
4 3 1 1 1 3
1
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.