Minimum Maximum Capability 
CodePlease Up Vote ⬆️⬆️ If it is helpfulApproachThis approach efficiently finds the minimum maximum capability required to rob exactly k houses without robbing
# Code
```python3 []
class Solution:
    def minCapability(self, nums: List[int], k: int) -> int:
        left, right = min(nums), max(nums)
        n = len(nums)
        
        while left < right:
            middle = (left + right) // 2
            thefts = 0
            index = 0

            while index < n:
                if nums[index] <= middle:
                    thefts += 1
                    index += 2  # Skip adjacent house to avoid consecutive thefts
                else:
                    index += 1

            if thefts >= k:
                right = middle  # Try for a smaller maximum capability
            else:
                left = middle + 1  # Increase capability to allow more thefts
                
        return left
```

## Please Up Vote ⬆️⬆️ If it is helpful

# Approach
<!-- Describe your approach to solving the problem. -->
This approach efficiently finds the **minimum maximum capability** required to rob exactly `k` houses without robbing two consecutive ones.

### Steps:
1. **Define search space**: The capability must be between `min(nums)` (best possible scenario) and `max(nums)` (worst scenario).
2. **Use binary search** to minimize the highest robbed house value:
   - Set `left` as the minimum house value and `right` as the maximum.
   - Check if it's possible to rob at least `k` houses while ensuring the robbed values do not exceed `middle`:
     - Iterate through `nums`, robbing houses while skipping adjacent ones.
     - Count the number of successful thefts.
   - If `thefts >= k`, we try to minimize the maximum capability by updating `right = middle`.
   - Otherwise, increase `left = middle + 1` to allow robbing higher-value houses.
3. **Return `left`**, which holds the minimum capability required.

# Complexity
- **Time complexity**: $$O(n \log M)$$, where `n` is the number of houses and `M` is the range between `min(nums)` and `max(nums)`.  
  - Binary search runs in $$O(\log M)$$.
  - Each iteration scans the array in $$O(n)$$.
  - Total complexity: $$O(n \log M)$$.

- **Space complexity**: $$O(1)$$, as only a few extra variables are used.
['Binary Search', 'Python3']