# 575.分糖果

## 问题描述
[575.分糖果](https://leetcode.cn/problems/distribute-candies/)

## 解题思路
最优思路为一种糖果只吃一颗。

## 代码
```cpp
class Solution {
public:
    int distributeCandies(vector<int>& candyType) {
        int n = candyType.size(), res = n / 2;
        std::unordered_set<int> type;
        for (auto i : candyType)
            type.insert(i);
        return res < type.size() ? res : type.size();
    }
};
```
