# -*- coding:utf-8 -*-
class Solution:
def MoreThanHalfNum_Solution(self, numbers):
# write code here
d={}
n=len(numbers)
if not numbers:
return 0
for i in range(n):
if numbers.count(numbers[i])>n//2:
return numbers[i]
return 0
剑指offer-数组中出现次数超过一半的数字(python)
猜你喜欢
转载自blog.csdn.net/qq_42738654/article/details/104287000
今日推荐
周排行