Swift Solution


  • 0
    J
    class Solution {
        func distributeCandies(_ candies: [Int]) -> Int {
            let quantityGet = candies.count / 2
            let numOfKinds = Set(candies).count
            return numOfKinds > quantityGet ? quantityGet : numOfKinds
        }
    }
    

Log in to reply
 

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