BinarySearch : O(N*logN)
Complexity
Time complexity: O(N*logN)

Space complexity: O(1)
Code


# Complexity
- Time complexity: O(N*logN)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    boolean check(int[] nums,int k,int mid){
        int c = 0;
        for(int i = 0;i<nums.length;i++){
            if(nums[i]<=mid  ){
                c++;
                i++;
            }
        }
        return c>=k;   
    }
    int binarySearch(int[] nums,int k){
        int st = 1,end =(int) (1e9);
        int ans = -1;
        while(st<=end){
            int mid  = st+(end-st)/2;
            if(check(nums,k,mid)){
                ans = mid;
                end = mid-1;
            }
            else st = mid+1;
        }
        return ans;
    }
    public int minCapability(int[] nums, int k) {
        return binarySearch(nums,k);
    }
}
```
['Java']