Python: Binary Search to solve this problem
python\nclass Solution:\n    def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:\n        left = 0\n        right = len(arr) - k\n      
```python\nclass Solution:\n    def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:\n        left = 0\n        right = len(arr) - k\n        \n        while left < right:\n            mid = (left + right) // 2\n            midValue = arr[mid]\n            \n            if x - arr[mid+k] <= midValue - x:\n                right = mid\n            else:\n                left = mid + 1\n        \n        return arr[left : left + k]\n```
['Binary Tree', 'Python', 'Python3']