1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 19:18:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/算法题(国内版)/problem (Chinese)/在排序数组中查找数字 I [zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof].html

31 lines
971 B
HTML
Raw Normal View History

2022-03-27 20:38:29 +08:00
<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>