1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/数组中出现次数超过一半的数字 [shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof].html
2022-03-29 12:43:11 +08:00

25 lines
655 B
HTML

<p>数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。</p>
<p>&nbsp;</p>
<p>你可以假设数组是非空的,并且给定的数组总是存在多数元素。</p>
<p>&nbsp;</p>
<p><strong>示例&nbsp;1:</strong></p>
<pre><strong>输入:</strong> [1, 2, 3, 2, 2, 2, 5, 4, 2]
<strong>输出:</strong> 2</pre>
<p>&nbsp;</p>
<p><strong>限制:</strong></p>
<p><code>1 &lt;= 数组长度 &lt;= 50000</code></p>
<p>&nbsp;</p>
<p>注意:本题与主站 169 题相同:<a href="https://leetcode-cn.com/problems/majority-element/">https://leetcode-cn.com/problems/majority-element/</a></p>
<p>&nbsp;</p>