C# Solution. Distinct version


  • 0
    S
    public class Solution 
    {
        public int DistributeCandies(int[] candies) 
        {
            int maxSisterCandiesNum = (int)(candies.Length * 0.5f);
            int candyKindNum = candies.Distinct().ToArray().Length;
            
            return (candyKindNum > maxSisterCandiesNum) ? maxSisterCandiesNum : candyKindNum;
        }
    }
    

  • 0
    K

    Hi! Thanks, the fastest solution for right now!
    Here benchmarks:

    0_1494440032545_upload-2be28740-c247-4e75-9997-a6e7546b8703


Log in to reply
 

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