✅✅Easy Java code|| Beats 99%||✅✅
\n# Approach\n Describe your approach to solving the problem. \nFirst find the range of candies to be distributed then,\nUse Binary Search to find the maximum n
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst find the range of candies to be distributed then,\nUse Binary Search to find the maximum number of candies distributed.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nlogn)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n\n# Code\n```\nclass Solution {\n    public int maximumCandies(int[] candies, long k) {\n        \n        long sum = 0;\n        for(int i = 0 ; i < candies.length; i++){\n            sum+= candies[i];\n        }\n        int left = 1;\n        int right = (int)(sum/k);\n        // System.out.println(sum+" "+right);\n        \n        while(left <= right){\n            int mid = (right - left) / 2 + left;\n            long count = 0;\n            \n            for(int i = 0 ; i < candies.length; i++){\n                count+= candies[i]/mid;\n            }\n            if(count >= k){\n                left = mid+1;\n            }\n            else{\n                right = mid-1;\n            }\n        }\n        return right;\n    }\n}\n```
['Java']