C++ Solution 2 lines Set


  • 0
    B
    class Solution {
    public:
        int distributeCandies(vector<int>& candies) {
           set<int> candy_statistics(candies.begin(), candies.end());
           return candy_statistics.size() >= candies.size()/2 ? candies.size()/2 : candy_statistics.size();
        }
    };
    

Log in to reply
 

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