Maxheap - Simple Solution
\nimport heapq as hq\nclass Solution:\n    def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:\n        \n        if len(arr) < k:\n    
```\nimport heapq as hq\nclass Solution:\n    def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:\n        \n        if len(arr) < k:\n            return []\n        \n        heap = []\n        \n        #Implement Max Heap by inserting negative distance values\n        for i in range(len(arr)):\n            d = -abs(x-arr[i])            \n            if len(heap) < k:             \n                hq.heappush(heap,(d,arr[i]))\n            else:\n                if -d < -heap[0][0]:\n                    hq.heappop(heap)\n                    hq.heappush(heap,(d,arr[i]))\n        \n        out = sorted([i[1] for i in heap])\n               \n        return out\n        \n```
['Heap (Priority Queue)', 'Python']