c++ solution
\n\n    int minCapability(vector& nums, int k) {\n    int s = 1, e = 1e9;\n    while (s < e) {\n        int mid = (s + e) / 2;\n        int take = 0;\n        f
\n\n    int minCapability(vector<int>& nums, int k) {\n    int s = 1, e = 1e9;\n    while (s < e) {\n        int mid = (s + e) / 2;\n        int take = 0;\n        for (int i = 0; i < nums.size() && take < k; i++) {\n            take += nums[i] <= mid;\n            i += nums[i] <= mid;\n        }\n        if (take < k)\n            s = mid + 1;\n        else\n            e = mid;\n    }\n    return s;\n    }\n\n
[]