🎁C++ Binary Search Easy Explaination Code
\n\nclass Solution\n{\npublic:\n    long long int maxPiles(vector<int> candies, long long int k)\n    {\n        long long int l = 1; // We can select an minimu
```\n\nclass Solution\n{\npublic:\n    long long int maxPiles(vector<int> candies, long long int k)\n    {\n        long long int l = 1; // We can select an minimum 1 element\n        long long int h = 0;\n        for (auto i : candies)\n        {\n            h += i;\n        }\n        if (k > h)\n        {\n            return 0;\n        }\n        h /= k; // at most selection\n                //  this ans for storing mid value\n        int ans = 0;\n        while (l <= h)\n        {\n            long long mid = (l + h) / 2;\n            long long int count = 0;\n            for (auto i : candies)\n            {\n                int tt = (i / mid);\n                count += tt;\n            }\n            if (count >= k)\n            {\n                ans = mid; // updating mid\n                l = mid + 1;\n            }\n            else\n            {\n                h = mid - 1;\n            }\n        }\n        return ans;\n    }\n    int maximumCandies(vector<int> &candies, long long k)\n    {\n        return maxPiles(candies, k);\n    }\n};\n```
['C', 'Binary Tree', 'C++']