LeetCode 题解:169. 多数元素,哈希表,JavaScript,详细注释

原题链接:https://leetcode-cn.com/problems/majority-element/
解题思路:
遍历数组,对每个出现的元素用哈希表计数,当数量大于n/2时,返回当前元素即可。
版权声明: 本文为 InfoQ 作者【Lee Chen】的原创文章。
原文链接:【http://xie.infoq.cn/article/a77d66b24a95ce1956897b361】。文章转载请联系作者。
评论