剑指 Offer 53 - I. 在排序数组中查找数字 Ibahttps://leetcode.cn/problems/zai-pai-xu-shu-zu-zhong-cha-zhao-shu-zi-lcof/
| 2023-8-30
0  |  阅读时长 0 分钟
Date
Aug 2, 2023
need_review
need_review
type
剑指 Offer(第 2 版)
undo
undo
难度
简单
统计一个数字在排序数组中出现的次数。
示例 1:
示例 2:
提示:
  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • nums 是一个非递减数组
  • -10^9 <= target <= 10^9
注意:本题与主站 34 题相同(仅返回值不同):https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/

解法1
暴力遍历
notion image
解法2
  • Giscus
目录