Binary_Search || Intutive || Intution-Explanation
Intution : We Know we had  to distribute  maximum candies , whenever face Problem in which we  have   to distribute  and finding the maximum or minium, See the 
Intution : We Know we had  to distribute  maximum candies , whenever face Problem in which we  have   to distribute  and finding the maximum or minium, See the Time Complexity if Time Complexity isaround 10^4, and your answer require optimal ways then think of dp solution, if Time Complexity is around 10^5 either it can be done by  sorting with greedy or binary search on ans. Now with this it was clear it is binary search on ans problem. So Just checked how can I distribute \n1. Search space can be 1 to sum(candies), Why\n Becuase you have to give them at least one so low = 1.\n 2. Just find the mid and check, if distributing mid candies it is possible to distribute if yes, then reduce your search space so that more optimal ans can be find.\n\n**Please UPVOTE Guys , If it helps, That motivates**\n```\nclass Solution {\npublic:\n    bool check(vector<int>& candies, long long k, long long mid) {\n        long long split = 0;\n        for(int i = 0; i < candies.size(); ++i) {\n            split += candies[i]/mid;\n        }   \n        return split>=k;\n    }\n    \n    int maximumCandies(vector<int>& candies, long long k) {\n        long long sum = 0;\n        for(int i = 0; i < candies.size(); ++i) {\n            sum += candies[i];\n        }\n        \n        long long start = 1, end = sum;\n        long long ans = 0;\n        \n        while(start <= end) {\n            long long mid = (start + end)/2;\n            if(check(candies, k, mid)) {\n                ans = mid;\n                start = mid + 1;\n            } else {\n                end = mid-1;\n            }\n        }\n        return ans;\n    }\n};\n\nTime Complexity : nlog(m}\nSpace Complexity: O(1)
[]