-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path575.py
18 lines (18 loc) · 786 Bytes
/
575.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
__________________________________________________________________________________________________
sample 900 ms submission
class Solution:
def distributeCandies(self, candies: List[int]) -> int:
totalCount = int(len(candies) / 2)
typesCount = len(set(candies))
return min(totalCount, typesCount)
__________________________________________________________________________________________________
sample 14520 kb submission
class Solution:
def distributeCandies(self, candies: List[int]) -> int:
d = {}
for i in candies:
d[i] = 1
if len(d) > len(candies) // 2:
return len(candies) // 2
return len(d)
__________________________________________________________________________________________________