✅✅C++ || Easy || Binary Search || 100% fast
Code\n\nclass Solution {\npublic:\n    int n;\n    bool isPossible(int x, int k, vector<int>& nums) {\n        int prev = -1, cnt = 0;\n\n        for(int i = 0;
# Code\n```\nclass Solution {\npublic:\n    int n;\n    bool isPossible(int x, int k, vector<int>& nums) {\n        int prev = -1, cnt = 0;\n\n        for(int i = 0; i < n; i++) {\n            if(nums[i] > x) continue;\n            if(prev != -1 && i == prev + 1) continue;\n            cnt++;\n            prev = i;\n        }\n        return cnt >= k;\n    }\n     \n    int minCapability(vector<int>& nums, int k) {\n        n = nums.size();\n        int l = 0, r = 1e9 + 2, ans = -1;\n\n        while(l <= r) {\n            int mid = (l + r) >> 1;\n            if(isPossible(mid, k, nums)) {\n                ans = mid;\n                r = mid - 1;\n            }\n            else l = mid + 1;\n        }        \n        return ans;        \n    }\n};\n```
['C++']