Marks :10
: 16 | : 7
Given an N-sized array of integers and value 'X', find the k closest integers with respect to 'X'.
It is guaranteed that X is present in the given array.
In case there are two values with same distance from 'X', prefer the smaller value.
First line contains a single integer corresponding to integer N.
Second line contains N space separated integers corresponding to the values in the given array.
Third line contains two space separated integers corresponding to 'k' and 'X'
Constraints
$$$ 1 \le k < N \le 100000 $$$
$$$ 1 \le arr[i] , X \le 10^9 $$$
Print K-closest integers in sorted order. (Ascending Order)
10 1 2 3 4 5 10 9 8 7 6 3 4
2 3 5
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.