Binary search
Code
# Code
```cpp []
class Solution {
public:
    bool isPossible(vector<int>& nums, int k, int mid){
        int n=nums.size();
        int rob=0;
        for(int i=0; i<n; i++){
            if(nums[i]<=mid){
                rob++;
                if(rob==k) return true;
                i++;
            }
        }
        return false;
    }
    int minCapability(vector<int>& nums, int k) {
        int l=0;
        int h=0;
        for(auto d:nums) h=max(h, d);
        int ans = INT_MAX;
        while(l<=h){
            int mid = l+(h-l)/2;
            if(isPossible(nums, k, mid)){
                ans=min(ans, mid);
                h=mid-1;
            }
            else l=mid+1;
        }
        return ans;
    }
};
```
['Array', 'Binary Search', 'C++']