Problem
Given a sorted list arr, an integer k and a value x, return the k values in arr that are closest to `x`, in ascending order. Value a is closer than b when |a - x| < |b - x|, or when they tie and a < b.
Example 1
- Input
- arr = [1, 2, 3, 4, 5], k = 4, x = 3
- Output
- [1, 2, 3, 4]
Example 2
- Input
- arr = [1, 2, 3, 4, 5], k = 4, x = -1
- Output
- [1, 2, 3, 4]
Example 3
- Input
- arr = [1, 3, 5, 7], k = 2, x = 4
- Output
- [3, 5]
Constraints
1 <= k <= arr.length <= 10^4-10^4 <= arr[i], x <= 10^4arr is sorted in ascending order.