0
点赞
收藏
分享

微信扫一扫

GPT-5:AI新时代的曙光与我们的准备

蓝莲听雨 2024-06-25 阅读 5

题目:

题解:

class Solution:
    def majorityElement(self, nums: List[int]) -> int:
        count = 0
        candidate = None

        for num in nums:
            if count == 0:
                candidate = num
            count += (1 if num == candidate else -1)

        return candidate
举报

相关推荐

0 条评论