Solved Using Binary Search (C++)
Complexity

Time complexity:
O(nlogn)


Space complexity:
O(1)

Code
# Complexity
- Time complexity:
O(nlogn)

- Space complexity:
O(1)

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

    // Helper function to check if we can rob 'k' houses with max value <= mid
    bool helper(vector<int> &nums, int k, int mid) {
        int i = 0, n = nums.size();
        
        while (i < n) {
            if (nums[i] <= mid) {  
                k--;  // Rob this house
                i += 2;  // Skip next house (no consecutive houses allowed)
            } else {
                i++;  // Skip this house and move ahead
            }
            if (k == 0) return true;  // Successfully robbed 'k' houses
        }
        
        return false;  // Could not rob 'k' houses within 'mid' limit
    }
    
    int minCapability(vector<int>& nums, int k) {
        int low = *min_element(nums.begin(), nums.end());  // Smallest house value
        int high = *max_element(nums.begin(), nums.end()); // Largest house value
        int ans = INT_MAX;
        
        while (low <= high) {
            int mid = low + (high - low) / 2;
            
            if (helper(nums, k, mid)) {
                ans = min(ans, mid);  // Store best minimum max value
                high = mid - 1;  // Try for a smaller value
            } else {
                low = mid + 1;  // Increase limit
            }
        }
        
        return ans;
    }
};

```
['C++']