Python版本没有吗
数组中出现次数超过一半的数字
http://www.nowcoder.com/questionTerminal/e8a1b01a2df14cb2b228b30ee6a92163
使用count计数功能
# -*- coding:utf-8 -*-
class Solution:
def MoreThanHalfNum_Solution(self, numbers):
# write code here
length = len(numbers)//2
for i in numbers:
if numbers.count(i)>length:
return i
return 0
基恩士成长空间 421人发布