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)/在排序数组中查找数字 I [zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof].html
2022-03-29 12:43:11 +08:00

31 lines
971 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>