C++ , 82.06%


  • 0
    R
    '''
    class Solution {
    public:
        int distributeCandies(vector<int>& candies) {
            sort(candies.begin() , candies.end());
            int count = 1;
            for (int i=1; i < candies.size() && count < candies.size() / 2; i++)
                count += (candies[i] > candies[i-1]) ;
            return count ;
        }
    };
    '''
    

Log in to reply
 

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