💯✅Best Solution in C++ || BinarySearch on Answer🔥💯
Complexity\n- Time complexity:\nnlog(1e9)     where n is the size of nums array\n\n- Space complexity:\nO(1)\n\n# Code\n## Please Upvote if u liked my Solution\
# Complexity\n- Time complexity:\nnlog(1e9)     where n is the size of nums array\n\n- Space complexity:\nO(1)\n\n# Code\n## **Please Upvote if u liked my Solution**\uD83E\uDD17\n```\nclass Solution {\npublic:\n    bool checkCapability(int x, vector<int>& nums, int k){\n        int count=0,prevInd=-2;\n        for(int i=0;i<nums.size();i++){\n            if(nums[i]<=x && (i-prevInd)>1){\n                count++;\n                prevInd=i;\n            }\n            if(count==k)\n                break;\n        }\n        if(count==k)\n            return true;\n        return false;\n    }\n    int minCapability(vector<int>& nums, int k) {\n        int ll=1,ul=1e9,mid,ans;\n        while(ll<=ul){\n            mid=ll+(ul-ll)/2;\n            if(checkCapability(mid,nums,k)){\n                ans=mid;\n                ul=mid-1;\n            }\n            else\n                ll=mid+1;\n        }\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'C++']