mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
25 lines
655 B
HTML
25 lines
655 B
HTML
<p>数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p>你可以假设数组是非空的,并且给定的数组总是存在多数元素。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
<pre><strong>输入:</strong> [1, 2, 3, 2, 2, 2, 5, 4, 2]
|
|
<strong>输出:</strong> 2</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>限制:</strong></p>
|
|
|
|
<p><code>1 <= 数组长度 <= 50000</code></p>
|
|
|
|
<p> </p>
|
|
|
|
<p>注意:本题与主站 169 题相同:<a href="https://leetcode-cn.com/problems/majority-element/">https://leetcode-cn.com/problems/majority-element/</a></p>
|
|
|
|
<p> </p>
|