Java Solution


  • 0
    C
        public int distributeCandies(int[] candies) {
            Set<Integer> set = new HashSet<>();
            for(int candy : candies){
                set.add(candy);
            }
            
            return set.size() > candies.length/2 ? candies.length/2 : set.size();
        }
    

Log in to reply
 

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