Standard Binary search No modification in Binary ssearch
Intuition\nWhen ever you see  this type of minimum-maximum problems where \nwhere you have to maximise some thing under some contraints.\nIn simple words you fi
# Intuition\nWhen ever you see  this type of minimum-maximum problems where \nwhere you have to maximise some thing under some contraints.\nIn simple words you find the maximum as well as minimum word in the same line you must think of binary search.\nTheir is very high chances that the problem can be solved using the \nbinary search. \n\n# Approach\nHere you do the standard binary search to find all the possible answers and than you return the most optimal answers of all the answers which you get in the binary search\n\n# Complexity\n- Time complexity:\nO(log(1e9)) * n;\n\n\n- Space complexity:\nO(1);\n\n# Code\n```\nclass Solution {\npublic:\n    int minCapability(vector<int>& nums, int k) {\n// Here you choose your answers range from 1 to 1e9:\n// as given in the constraints.\n// You can also choose your range from min(All the elements)\n// to max//(all the elements) in the array.\n\n// Now the very standard Binary search\n\n        int left = 1; \n        int right = 1e9;\n        int n = nums.size();\n        int maxi = 1e9;\n        while(left <= right){\n            int mid = (left + right)/2;\n            int take = 0; \n// Mid can be your possible answers\n\n            for(int i = 0; i<n; i++){\n                if(nums[i] <= mid){\n                    take += 1;\n                    i++;\n// As given in the question that you cannot take \n// two consecutive houses that why we have done i++ here\n\n                }\n            }\n// If we have taken more than K houses That is not allowed \n// hence we reduce the maximum amount of money allowed\n                if(take > k){\n                    right = mid-1;\n                }\n// If we were unable to take K houses than it is okay but in \n// order maximise the number of houses we do increase left.\n                else if(take < k){\n                    left = mid + 1;\n                    maxi = min(maxi, mid);      \n                }\n// if we were able to get exactly k houses than the answer is \n//possible one so we check it if it is less than previous stored answers\n                else{\n                     maxi = min(maxi, mid);\n                     right = mid - 1;\n                }\n            \n        }\n        return maxi;;\n    }\n};\n```
['Binary Search', 'Greedy', 'C++']