Given a sorted array, a number X, and a value k, find the k closest numbers to X in the array.
{
"arr": [
5,
6,
7,
8,
9
],
"k": 3,
"x": 7
}[
6,
7,
8
]{
"arr": [
1,
2,
3,
4,
5
],
"k": 4,
"x": 3
}[
1,
2,
3,
4
]{
"arr": [
10,
20,
30,
40,
50
],
"k": 2,
"x": 35
}[
30,
40
]Sign in to Run Code and Submit