DAILY LEETCODE SOLUTION || EASY C++ SOLUTION
\nclass Solution {\n    static bool comp(pair<int,int> &a,pair<int,int> &b)\n    {\n        if(a.first==b.first) return a.second<b.second;\n        return a.fir
```\nclass Solution {\n    static bool comp(pair<int,int> &a,pair<int,int> &b)\n    {\n        if(a.first==b.first) return a.second<b.second;\n        return a.first<b.first;\n    }\npublic:\n    vector<int> findClosestElements(vector<int>& arr, int k, int x) {\n        vector<pair<int,int>> vec;\n        for(int i=0;i<arr.size();i++)\n        {\n            vec.push_back({abs(arr[i]-x),arr[i]});\n        }\n        sort(vec.begin(),vec.end(),comp);\n        vector<int> ans;\n        for(int i=0;i<k;i++)\n        {\n            ans.push_back(vec[i].second);\n        }\n        sort(ans.begin(),ans.end());\n        return ans;\n    }\n};\n```
['Array', 'C', 'Sorting']