658. Find Closest Elements || C++ || Easy Solution Daily here at https://striver.bio.link/
Success || Details :  Popular views | | Daily Easy Solutioins Here - https://striver.bio.link/\nRuntime: 47 ms, faster than 92.72% of C++ online submissions for
**Success || Details :  Popular views | | Daily Easy Solutioins Here - [https://striver.bio.link/](https://striver.bio.link/)\nRuntime: 47 ms, faster than 92.72% of C++ online submissions for Find K Closest Elements.**\n**Memory Usage: 31 MB, less than 93.94% of C++ online submissions for Find K Closest Elements.**\n\n### **LinkedIn Profile - [https://www.linkedin.com/in/shivam-kumar-bitian/](http://www.linkedin.com/in/shivam-kumar-bitian/)**\n\n```\nclass Solution {\npublic:\n    vector<int> findClosestElements(vector<int>& A, int k, int x) {\n        int left = 0, right = A.size() - k;\n        while (left < right) {\n            int mid = (left + right) / 2;\n            if (x - A[mid] > A[mid + k] - x)\n                left = mid + 1;\n            else\n                right = mid;\n        }\n        return vector<int>(A.begin() + left, A.begin() + left + k);\n    }\n};\n```
['Array', 'Two Pointers', 'Binary Search', 'C', 'Sorting', 'Heap (Priority Queue)']