16 lines
413 B
Python
16 lines
413 B
Python
#!/usr/bin/python
|
|
# yigid balaban <fyb@fybx.dev>
|
|
# neetcode 2024
|
|
# easy / distribute candies
|
|
|
|
def solution(candyType: list[int]) -> int:
|
|
howManyTypes = len(set(candyType))
|
|
permitAmount = len(candyType) // 2
|
|
return permitAmount if howManyTypes >= permitAmount else howManyTypes
|
|
|
|
|
|
print(solution([1,1,2,2,3,3]) == 3)
|
|
print(solution([1,1,2,3]) == 2)
|
|
print(solution([6,6,6,6]) == 1)
|
|
|