C++ solution using Binary Search
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n# Approach\n Describe your approach to solving the problem. \nbinary search approac
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nbinary search approach similar to koko eating bananas\n\n# Complexity\n- Time complexity:\n- O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(1)\n\n\n# Code\n```\nclass Solution {\npublic:\n    bool noOfCandies(vector<int> candies,int n,long long candiesPerChild,long long totalNoOfKids){\n        long long noOfKidsWithCandies=0;\n        for(int i=0;i<n;i++){\n            noOfKidsWithCandies+=candies[i]/candiesPerChild;\n            if(noOfKidsWithCandies>=totalNoOfKids){\n                return true;\n            }\n        }\n        return false;\n    }    \n    int maximumCandies(vector<int>& candies, long long k) {\n        int n=candies.size();\n        long long low=1;\n        long long high=0;\n        for(int i=0;i<n;i++){\n            high+=candies[i];\n        }\n        if(k>high){\n            return 0;\n        }\n        while(low<=high){\n            long long mid=low+(high-low)/2;\n            if(noOfCandies(candies,n,mid,k)){\n                low=mid+1;\n            }\n            else{\n                high=mid-1;\n            }\n        }\n        return high;\n    }\n};\n```
['C++']