Simple Solution using binary search 92% beats 🔥🔥| java 
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public boolean canDist(int candies[],int mid , long k){

        for(int i=0;i<candies.length;i++){
            k -= candies[i]/mid;
            if(k<=0) return true;
        }
        return k<=0;
    }
    public int maximumCandies(int[] candies, long k) {
        long sum = 0;
        int n = candies.length;
        int maxCand = 0;
        for(int i=0;i<n;i++){
            sum += candies[i];
            maxCand = Math.max(maxCand,candies[i]);
        }    
        // 8 7 6 5 4 3 2 1 (range from 1 to maxElement in candies arr)
        // Apply binary search on this
        int l = 1;
        int r = maxCand;
        int res = 0;
        while(l<=r){
            int mid = l + (r-l)/2;
            if(canDist(candies,mid,k)){
                res = mid;
                l = mid +1 ;
            }
            else{
                r = mid -1;
            }
        }
        return res;
    }
}
```
['Binary Search', 'Java']