Difficulty Level : Easy
Submissions : 81
Asked In :
Marks :10
: 1 | : 0
There are 2 boys in a class who have been given a target, $$$k$$$ by their class teacher. The students have an array of $$$n$$$ elements $$$a_i$$$. Their task to remove the minimum number of elements from this array such that the absolute difference between any two elements in the resulting array is lesser than or equal to k. Find the minimum number of elements that the boys need to remove from the array.
Constraints
The first line of the input contains two integers $$$n$$$ and $$$k$$$ representing the length of the array and the maximum difference desired. The next line contains a sequence of n integers $$$a_i$$$
Output a single integer which is the answer to the problem
3 3 5 10 2
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.