scala version


  • 1
    M
      def distributeCandies(candies: Array[Int]): Int = {
        var set = Set.empty[Int]
        for (candy <- candies) set += candy
        if (set.size < candies.length / 2) set.size else candies.length / 2
      }
    

Log in to reply
 

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