Skip to main content

575 - Distribute Candies

Details

KeyValue
Linkhttps://leetcode.com/problems/distribute-candies/
LanguagePython 3
Runtime829 ms, faster than 91.21% of Python3 online submissions for Distribute Candies
Memory Usage16.2 MB, less than 69.49% of Python3 online submissions for Distribute Candies
DatastructuresList[int]
AlgorithmsReverse string

Procedure

  1. TBD...

Code

class Solution:
def distributeCandies(self, candies: List[int]) -> int:
candies_to_eat = len(candies) / 2
candy_types = len( set(candies) )
return int( min(candies_to_eat, candy_types) )