🔥 Well Explained Solution | Python | Binary Search
IntuitionWe need to find the minimum "maximum capability" a robber must have to rob at least k non-adjacent houses. This suggests a binary search on the answer
# Intuition
We need to find the minimum "maximum capability" a robber must have to rob at least k non-adjacent houses. This suggests a binary search on the answer since we are looking for a minimum threshold.
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
1. **Binary Search on Capability:** Instead of iterating over every possible capability, we search between min(nums) and max(nums).
2. **Feasibility Check (possible_robbery):** We greedily select houses with values ≤ mid, ensuring no two adjacent houses are picked.
3. **Adjust Search Space:** If k houses can be robbed, try a lower capability; otherwise, increase the threshold.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: 
- O(N*logM), where N is the number of houses and M is the range of values in nums.
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minCapability(self, nums: List[int], k: int) -> int:
        def possible_robbery(min_cap):
            count = 0
            i = 0
            while i < len(nums):
                if nums[i] <= min_cap:
                    count += 1
                    i += 1 
                i += 1 
            return count >= k

            
        l=min(nums)
        r=max(nums)
        ans=0
        while l<=r:
            mid=(r-l)//2 +l

            if possible_robbery(mid):
                ans=mid
                r=mid-1
                
            else:
                l=mid+1
            
        
        return ans
```
['Binary Search', 'Python3']