Leetcode 169. Majority Element
Apr 16, 2019#Algorithms
题意
找出数组中出现次数超过数组长度一半的那个元素。
题目来源:https://leetcode.com/problems/majority-element/
提交次数:1/1
代码效率:20.20%
分析
哈希表,键存储元素,值存储个数,值大于数组长度 1/2 就返回。
代码
1 | class Solution { |
找出数组中出现次数超过数组长度一半的那个元素。
题目来源:https://leetcode.com/problems/majority-element/
提交次数:1/1
代码效率:20.20%
哈希表,键存储元素,值存储个数,值大于数组长度 1/2 就返回。
1 | class Solution { |