2025-07-30 15:07:19 +0000 UTC

Distribute Candies

Code

class Solution:
    def distributeCandies(self, candyType: List[int]) -> int:
        types = set()
        max_length = len(candyType) // 2
        for candy in candyType:
            types.add(candy)
            if len(types) >= max_length:
                return max_length
        return len(types)