Simple Binary Search
Intuition\nBinary Search and check condition every search\n\n# Approach\nBinary Search\n\n# Complexity\n- Time complexity:\nO(n*logn)\n\n- Space complexity:\nO(
# Intuition\nBinary Search and check condition every search\n\n# Approach\nBinary Search\n\n# Complexity\n- Time complexity:\n$$O(n*logn)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n``` python\nclass Solution:\n    def maximumCandies(self, candies: List[int], k: int) -> int:\n        def check(candyPerPile):\n            pile = 0\n            for candy in candies:\n                pile += candy // candyPerPile\n            \n            return pile >= k\n\n        left = 1\n        right = sum(candies) // k\n\n        while left <= right:\n            mid = (left + right) // 2\n\n            if check(mid):\n                left = mid + 1       \n            else:\n                right = mid - 1\n        return right\n\n```
['Binary Search', 'Python3']