Easy understandable C++ solution || Binary search on answers approach
\n\n# Code\n\nclass Solution {\npublic:\n    bool isPossible(vector<int>& ranks, long long mid, int cars){\n        long long count = 0;\n        for(int i=0; i
\n\n# Code\n```\nclass Solution {\npublic:\n    bool isPossible(vector<int>& ranks, long long mid, int cars){\n        long long count = 0;\n        for(int i=0; i<ranks.size(); i++){\n            long long temp;\n            temp = mid/ranks[i];\n            count += sqrt(temp);\n        }\n\n        if(count >= cars){\n            return true;\n        }\n        return false;\n    }\n\n\n    long long repairCars(vector<int>& ranks, int cars) {\n        long long mini = *min_element(ranks.begin(), ranks.end());\n        long long start = 1, end = mini*cars*cars;\n        long long ans = 0;\n        while(start <= end){\n            long long mid = start + (end-start)/2;\n            if(isPossible(ranks, mid, cars)){\n                ans = mid;\n                end = mid-1;\n            }\n            else{\n                start = mid+1;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'C++']