[Simple][Java][Beats 100%]
IntuitionBinary search is used to efficiently determine this minimum capability by narrowing down the range based on whether the current capability allows the r
# Intuition
Binary search is used to efficiently determine this minimum capability by narrowing down the range based on whether the current capability allows the robber to rob k houses.
# Approach
<!-- Describe your approach to solving the problem. -->
**Binary Search** : We perform binary search over the possible values of the capability, from the minimum to the maximum value in the nums array.

**Count Valid Steals** : For each midpoint mid, we count how many houses can be robbed without stealing from adjacent ones.

**Update Range** : If it's possible to steal from at least k houses, we try to reduce the capability. Otherwise, we increase it.
# Complexity
- Time complexity: O(n * log(m)), where n is the length of the nums array, and m is the maximum possible value in nums.
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1), since we only use a few extra variables for calculations.
<!-- Add your space complexity here, e.g. $$O(n)$$ -->


# Code
```java []
class Solution {

    public int minCapability(int[] nums, int k) {
        int mid = 0;
        int count;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int ans = Integer.MAX_VALUE;

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

        while (min <= max) {
            mid = min + ((max - min) >> 1);
            count = 0;
            for (int i = 0; i < nums.length; i++) {
                if (mid >= nums[i]) {
                    count++;
                    i++;
                }
            }
            if (count >= k) {
                ans = mid;
                max = mid - 1;
            } else {
                min = mid + 1;
            }
        }
        return ans;
    }
}
```
['Java']