Find K closest elements to given Value in Unsorted Array
Given an unsorted array arr[] and two numbers X and K, the task is to find K closest values to X in arr[]. Examples: Input: arr[] = {10, 2, 14, 4, 7, 6}, X = 5, K = 3 Output: 4 6 7Explanation: Three closest values of x are 4, 6 and 7. Input: arr[] = {-10, -50, 20, 17, 80}, X = 20, K = 2Output: 17 20