✅ 🔥 Python3 | Binary search | Faster 100% ✅ 🔥
IntuitionSince each student needs to have an equal number of candies, we divide the array into different groups, ensuring the total is divisible by the number o
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Since each student needs to have an equal number of candies, we divide the array into different groups, ensuring the total is divisible by the number of students. Then, we check whether it is possible to distribute the candies accordingly. 
# Approach
<!-- Describe your approach to solving the problem. -->
Use binary search to determine if it is possible to distribute the given number of candies among the students. If possible, adjust the left boundary; otherwise, reduce the right boundary to mid - 1.

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

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

# Code
```python3 []
class Solution:
    def maximumCandies(self, candies: List[int], k: int) -> int:
        sum = 0
        for i in range(len(candies)):
            sum += candies[i]
        if sum < k:
            return 0
        def isPossible(mid):
            count = 0
            for i in range(len(candies)):
                if candies[i] >= mid:
                    count += candies[i] // mid
            if count >= k:
                return True
            return False
        left, right = 0, sum // k
        #print(f"{left} {right} {sum}")
        while left < right:
            mid = left + (right - left+1) // 2
            #print(f"{left} {right} mid : {mid}")
            if isPossible(mid):
                left = mid
            else:
                right = mid - 1
        return left
```
['Python3']