Easy-Peasy using priority queue( C++)
``` cpp\nclass Solution {\npublic:\n    vector findClosestElements(vector& arr, int k, int x) {\n        priority_queue >heap;\n        int n=arr.size();\n     
``` cpp\nclass Solution {\npublic:\n    vector<int> findClosestElements(vector<int>& arr, int k, int x) {\n        priority_queue<pair<int,int> >heap;\n        int n=arr.size();\n        for(int i=0;i<n;i++)\n        {\n            heap.push({abs(x-arr[i]),arr[i]});\n            if(heap.size()>k)\n            {\n                heap.pop();\n            }\n        }\n        vector<int> sol;\n        while(heap.size()>0)\n        {\n            sol.push_back(heap.top().second);\n            heap.pop();\n        }\n        sort(sol.begin(),sol.end());\n        return sol;\n    }\n};
['Heap (Priority Queue)', 'C++']