mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
31 lines
971 B
HTML
31 lines
971 B
HTML
<p>统计一个数字在排序数组中出现的次数。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong> nums = [<code>5,7,7,8,8,10]</code>, target = 8
|
||
<strong>输出:</strong> 2</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong> nums = [<code>5,7,7,8,8,10]</code>, target = 6
|
||
<strong>输出:</strong> 0</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>0 <= nums.length <= 10<sup>5</sup></code></li>
|
||
<li><code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code></li>
|
||
<li><code>nums</code> 是一个非递减数组</li>
|
||
<li><code>-10<sup>9</sup> <= target <= 10<sup>9</sup></code></li>
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>注意:</strong>本题与主站 34 题相同(仅返回值不同):<a href="https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/">https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/</a></p>
|