C++ Easy Binary search Solution 100% Runtime 100% Memory efficient
\nclass Solution {\npublic:\n    int minCapability(vector<int>& a, int k) {\n        int n=a.size();\n        \n        int lo=*min_element(a.begin(),a.end())-1
```\nclass Solution {\npublic:\n    int minCapability(vector<int>& a, int k) {\n        int n=a.size();\n        \n        int lo=*min_element(a.begin(),a.end())-1,hi=*max_element(a.begin(),a.end())+1;\n        auto good = [&](const int mid) {\n            int l=-2;\n            int cnt=0;\n            for(int i=0;i<n;i++){\n                if(a[i]<=mid&&l!=i-1){\n                    cnt++;\n                    l=i;\n                }\n            }\n            return cnt>=k;\n        };\n        while(hi>lo+1){\n            int mid=lo+(hi-lo)/2;\n            \n            if(good(mid)){\n                hi=mid;\n            }\n            else\n                lo=mid;\n        }\n        // good(2);\n        return hi;\n    }\n};\n```
['Array', 'C', 'Binary Tree']