Skip to content
LC-0575 Easy LeetCode

575. Distribute Candies

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 69% Topics: Array, Hash Table
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

class Solution(object):

    def distributeCandies(self, candies):
        """
        :type candies: List[int]
        :rtype: int
        """
        lookup = set(candies)
        return min(len(lookup), len(candies)/2)

Solution from kamyu104/LeetCode-Solutions · MIT