分糖果(凑字数)

2021/11/1 23:42:27

本文主要是介绍分糖果(凑字数),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

class Solution:
    def distributeCandies(self, candyType: List[int]) -> int:       
        n = len(candyType)/2
        candyType1 = set(candyType)
        if len(candyType1) >= n :
            return int(n)
        else :
            return len(candyType1)



这篇关于分糖果(凑字数)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程