C++✅✅| 100% beats | Both DP and Binary search approch | Simplest approach🚀🚀 
Code


# Code
```cpp []
class Solution {
public:

    int func(vector<int> &nums, int k, int i, int n, int curr, vector<vector<vector<int>>> &dp) {
        if(k == 0) return nums[curr];
        if(i >= n) return 1e9;
        if(dp[i][k][curr + 1] != -1) return dp[i][k][curr + 1];
        int take = 1e9, nottake = 1e9;
        int idx = -1;
        if(curr == -1 || nums[curr] < nums[i]) idx = i;
        else idx = curr;
        take = func(nums, k - 1, i + 2, n, idx, dp);
        nottake = func(nums, k, i + 1, n, curr, dp);
        return dp[i][k][curr + 1] = min(take, nottake);
    }

    int minCapability(vector<int>& nums, int k) {
        int n = nums.size();
        // DP (MLE)
        // vector<vector<vector<int>>> dp(n, vector<vector<int>> (k + 1, vector<int>(n, -1)));
        // return func(nums, k, 0, n, -1, dp);

        //Binary Search 
        int l = *min_element(nums.begin(), nums.end()), 
            h = *max_element(nums.begin(), nums.end());

        auto check = [&](int mid) {
            int cnt = 0;
            for(int i = 0; i < n; i++) {
                if(nums[i] <= mid) {
                    cnt++;
                    i++;
                }
            }
            return cnt >= k;
        };

        int ans = -1;
        while(l <= h) {
            int mid = l + (h - l) / 2;
            if(check(mid)) {
                ans = mid;
                h = mid - 1;
            }
            else {
                l = mid + 1;
            }
        }
        return ans;
    }
};
```
['Array', 'Binary Search', 'Memoization', 'C++']