Java solution | using binary search
\nprivate boolean isPossible(int[] candies,int max,long k){\n        long sum = 0;\n        for(int i = 0; i<candies.length;i++){\n            sum += (candies[i
```\nprivate boolean isPossible(int[] candies,int max,long k){\n        long sum = 0;\n        for(int i = 0; i<candies.length;i++){\n            sum += (candies[i]/max);\n        }\n        if(sum>=k){\n            return true;\n        }\n        return false;\n    }\n    public int maximumCandies(int[] candies, long k) {\n        int s = 1;\n        int e = 0;\n        for(int i = 0; i< candies.length;i++){\n            e = Math.max(e,candies[i]);                  // ans can\'t be more than the height number in the array so take end, the max candie from array.\n        }\n        int ans = 0;\n        while(s<=e){\n            int mid = s+(e-s)/2;\n            if(isPossible(candies,mid,k)){       // if posible to distribute candies with mid then store ans and increase start to mid + 1, Becoz we need maximum possible ans according to question.\n                ans = mid;\n                s = mid+1;\n            }\n            else{\n                e = mid-1;\n            }\n        }\n        return ans;\n    }\n```
['Binary Tree', 'Java']