题意
找出数组中出现次数超过数组长度一半的那个元素。
题目来源:https://leetcode.com/problems/majority-element/
标记难度:Easy
提交次数:1/1
代码效率:20.20%
分析
哈希表,键存储元素,值存储个数,值大于数组长度 1/2 就返回。
代码
1 |
class { |
找出数组中出现次数超过数组长度一半的那个元素。
题目来源:https://leetcode.com/problems/majority-element/
标记难度:Easy
提交次数:1/1
代码效率:20.20%
哈希表,键存储元素,值存储个数,值大于数组长度 1/2 就返回。
1 |
class { |
近期评论