Easy & Simple C++ solution using Binary Search 100% fast | O(1) space | O(n logn) time
Intuition\n Describe your first thoughts on how to solve this problem.      \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->     \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n log(n)) \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int check(vector<int>&a, int mid){\n        int last_picked = -2;\n        int cnt= 0 ;\n        for(int i = 0 ;i<a.size();i++){\n            if(a[i]<=mid && last_picked!=i-1){\n                last_picked = i;\n                cnt++;\n            }\n        }\n        return cnt;\n    }\n    int minCapability(vector<int>& a, int k) {\n        int n = a.size();        \n        int lo = *min_element(a.begin(),a.end());\n        int hi = *max_element(a.begin(),a.end());\n        int ans = - 1;\n        while(hi>=lo){\n            int mid = (hi+lo)/2;\n            if(check(a,mid)>=k){\n                ans = mid;\n                hi = mid-1;\n            }\n            else{\n                lo = mid+1;\n            }\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'C++']