Minimum Capability to Rob at Least k Houses Without Adjacent Robbery
IntuitionWe need to find the minimum capability a thief should have to rob at least k houses while ensuring no two adjacent houses are robbed.Since the capabili
# Intuition
We need to find the minimum capability a thief should have to rob at least k houses while ensuring no two adjacent houses are robbed.

Since the capability defines the maximum amount the thief can rob from any selected house, we should minimize this value while still being able to rob at least k houses.
# Approach
Find the Search Space:

The capability must be between the minimum and maximum values in nums, so we initialize:
low = min(nums[]) (smallest house value)
high = max(nums[]) (largest house value)
Binary Search on Capability (cap):

Perform binary search on cap, the maximum amount the thief can rob in one attempt.
For each mid-value (cap), check if we can rob at least k houses without robbing two adjacent ones.
Check Feasibility (canRobWithCapability method):

Iterate through nums[]:
If a house value ≤ cap, rob it and skip the next house.
Count how many houses were robbed.
If the count is at least k, update the search range.
Result:

The smallest cap that allows robbing at least k houses is our answer.
# Complexity
- Time complexity:  O(nlog(max−min))
- Space complexity: O(1) (constant extra space)
# Code
```java []
class Solution {
    public int minCapability(int[] nums, int k) {
        int low = Integer.MAX_VALUE, high = Integer.MIN_VALUE;

        for (int num : nums) {
            low = Math.min(low, num);
            high = Math.max(high, num);
        }

        while (low < high) {
            int mid = (low + high) / 2;
            if (canRobWithCapability(nums, k, mid)) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        
        return low;
    }

    private boolean canRobWithCapability(int[] nums, int k, int cap) {
        int count = 0;
        int i = 0;
        
        while (i < nums.length) {
            if (nums[i] <= cap) {
                count++;
                i++;
            }
            i++;
        }
        
        return count >= k;
    }
}

```
['Binary Search', 'Greedy', 'Java']