229. Majority Element II

xiaoxiao2021-02-27  169

class Solution(object):     def majorityElement(self, nums):         """         :type nums: List[int]         :rtype: List[int]         """         t = len(nums) / 3

        return [n for n in set(sorted(nums)[t::max(t,1)]) if nums.count(n) > t]

找出超过3个数的元素

转载请注明原文地址: https://www.6miu.com/read-15545.html

最新回复(0)