C++ one line solution


  • 0
    Z
    class Solution {
    public:
        int distributeCandies(vector<int>& candies) {
            return std::min(candies.size() / 2, unordered_set<int>(begin(candies), end(candies)).size());
        }
    };

Log in to reply
 

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