easy Python solution using Set


  • 0
    D

    class Solution(object):
    def distributeCandies(self, candies):
    """
    :type candies: List[int]
    :rtype: int
    """
    temp = set(candies)
    m,n = len(temp),0.5*len(candies)
    if m <= n:
    return m
    else:
    return int(n)


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.