BEST C++ solution || List of 8 similar VERY IMP binary search questions
List of similar binary search questions \n- Koko Eating bananas - Leetcode\n- Find the Smallest Divisor Given a Threshold - Leetcode\n- Minimum Number of Days t
# List of similar binary search questions \n- [Koko Eating bananas - Leetcode](https://leetcode.com/problems/koko-eating-bananas/solutions/3750804/best-c-solution-list-of-7-similar-very-imp-binary-search-questions/)\n- [Find the Smallest Divisor Given a Threshold - Leetcode](https://leetcode.com/problems/find-the-smallest-divisor-given-a-threshold/solutions/3746201/best-c-solution-pure-binary-search-approach-beats-98-84/)\n- [Minimum Number of Days to Make m Bouquets - Leetcode](https://leetcode.com/problems/minimum-number-of-days-to-make-m-bouquets/solutions/3751751/best-c-solution-list-of-similar-very-imp-binary-search-questions/)\n- [Capacity To Ship Packages Within D Days - Leetcode](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/solutions/3751752/best-c-solution-list-of-similar-very-imp-binary-search-questions/)\n- [Minimized Maximum of Products Distributed to Any Store - Leetcode](https://leetcode.com/problems/minimized-maximum-of-products-distributed-to-any-store/solutions/3750918/best-c-solution-list-of-similar-very-imp-binary-search-questions/) \n- [Book Allocation - Coding Ninjas](https://www.codingninjas.com/studio/problems/ayush-and-ninja-test_1097574?source=youtube&campaign=love_babbar_codestudio2&leftPanelTab=0)\n- [Aggressive cows - Coding Ninjas](https://www.codingninjas.com/studio/problems/aggressive-cows_1082559?source=youtube&campaign=love_babbar_codestudio2&leftPanelTab=1)\n- [Painter\'s partition - Coding Ninjas](https://www.codingninjas.com/studio/problems/painter\'s-partition-problem_1089557?source=youtube&campaign=love_babbar_codestudio2&leftPanelTab=0)\n\n# Code\n```\nclass Solution {\npublic:\n    long long repairCars(vector<int>& ranks, int cars) {\n        long long int start = 1, end = 1e14, ans = 0;\n        while(start<=end){\n            long long mid = start+(end-start)/2, carCount = 0;\n            for(int i=0; i<ranks.size(); i++){\n                carCount += sqrt(mid/ranks[i]);\n            }\n            if(carCount >= cars)\n                ans = mid, end = mid-1;\n            else\n                start = mid+1;\n        } \n        return ans;\n    }\n};\n```
['Binary Search', 'C++']